Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
wasm-watermarker
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nagayama15
wasm-watermarker
Commits
22e43969
Verified
Commit
22e43969
authored
Jan 06, 2020
by
nagayama15
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update benchmark
parent
11f605fa
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
72 deletions
+17
-72
benchmark.js
example/ammo.js/benchmark.js
+15
-4
stress.js
example/ammo.js/stress.js
+2
-68
No files found.
example/ammo.js/benchmark.js
View file @
22e43969
require
(
"./testutils"
);
require
(
"./testutils"
);
const
stress
=
require
(
"./stress"
);
const
stress
=
require
(
"./stress"
);
const
WARM
=
3
;
const
N
=
10
+
WARM
;
(
async
()
=>
{
(
async
()
=>
{
const
runBench
=
dir
=>
{
const
runBench
=
dir
=>
{
const
Ammo
=
require
(
`./
${
dir
}
/ammo.wasm`
);
const
Ammo
=
require
(
`./
${
dir
}
/ammo.wasm`
);
return
new
Promise
(
resolve
=>
{
return
new
Promise
(
resolve
=>
{
console
.
log
(
`Run bench:
${
dir
}
`
);
console
.
error
(
`
${
dir
}
`
);
// Wrap `Ammo()` by real `Promise` object because it returns just Promise-like object
// Wrap `Ammo()` by real `Promise` object because it returns just Promise-like object
// and awaiting it acts buggy.
// and awaiting it acts buggy.
Ammo
().
then
(
Ammo
=>
{
Ammo
().
then
(
Ammo
=>
{
stress
(
Ammo
);
const
durs
=
[];
resolve
();
for
(
let
i
=
0
;
i
<
N
;
i
++
)
{
const
dur
=
stress
(
Ammo
);
durs
.
push
(
dur
);
console
.
error
(
dur
);
}
resolve
({
dir
,
durs
});
});
});
});
});
};
};
...
@@ -33,7 +41,10 @@ const stress = require("./stress");
...
@@ -33,7 +41,10 @@ const stress = require("./stress");
"dist/ammo-3-fe8191b3"
"dist/ammo-3-fe8191b3"
];
];
const
results
=
[];
for
(
wasm
of
wasms
)
{
for
(
wasm
of
wasms
)
{
await
runBench
(
wasm
);
results
.
push
(
await
runBench
(
wasm
)
);
}
}
console
.
log
(
JSON
.
stringify
(
results
));
})();
})();
example/ammo.js/stress.js
View file @
22e43969
// From ammo.js/tests/stress.js
// From ammo.js/tests/stress.js
function
stress
(
Ammo
)
{
function
stress
(
Ammo
)
{
// Stress test
// Stress test
var
TEST_MEMORY
=
0
;
var
readMemoryCeiling
,
malloc
;
if
(
TEST_MEMORY
)
{
(
function
()
{
try
{
STATICTOP
;
readMemoryCeiling
=
function
()
{
return
STATICTOP
+
_sbrk
.
DATASIZE
;
};
malloc
=
_malloc
;
}
catch
(
e
)
{
var
mapping
=
getClosureMapping
();
var
key
=
"0"
;
readMemoryCeiling
=
eval
(
"(function() { return "
+
mapping
[
"STATICTOP"
]
+
" + "
+
mapping
[
"_sbrk$DATASIZE"
]
+
" })"
);
malloc
=
eval
(
mapping
[
"_malloc"
]);
}
})();
}
function
benchmark
()
{
function
benchmark
()
{
var
collisionConfiguration
=
new
Ammo
.
btDefaultCollisionConfiguration
();
var
collisionConfiguration
=
new
Ammo
.
btDefaultCollisionConfiguration
();
var
dispatcher
=
new
Ammo
.
btCollisionDispatcher
(
collisionConfiguration
);
var
dispatcher
=
new
Ammo
.
btCollisionDispatcher
(
collisionConfiguration
);
...
@@ -100,58 +73,19 @@ function stress(Ammo) {
...
@@ -100,58 +73,19 @@ function stress(Ammo) {
bodies
.
push
(
body
);
bodies
.
push
(
body
);
});
});
var
memoryStart
;
var
startTime
=
Date
.
now
();
var
startTime
=
Date
.
now
();
if
(
TEST_MEMORY
)
malloc
(
5
*
1024
*
1024
);
// stress memory usage
var
NUM
=
150000
;
var
NUM
=
150000
;
for
(
var
i
=
0
;
i
<
NUM
;
i
++
)
{
for
(
var
i
=
0
;
i
<
NUM
;
i
++
)
{
if
(
i
===
250
&&
TEST_MEMORY
)
memoryStart
=
readMemoryCeiling
();
dynamicsWorld
.
stepSimulation
(
1
/
60
,
10
);
dynamicsWorld
.
stepSimulation
(
1
/
60
,
10
);
}
}
var
endTime
=
Date
.
now
();
var
endTime
=
Date
.
now
();
return
(
endTime
-
startTime
)
/
1000
;
if
(
TEST_MEMORY
)
assertEq
(
readMemoryCeiling
(),
memoryStart
,
"Memory ceiling must remain stable!"
);
print
(
"total time: "
+
((
endTime
-
startTime
)
/
1000
).
toFixed
(
3
));
}
function
testDestroy
()
{
var
NUM
=
1000
;
// enough to force an increase in the memory ceiling
var
vec
=
new
Ammo
.
btVector3
(
4
,
5
,
6
);
var
memoryStart
=
readMemoryCeiling
();
for
(
var
i
=
0
;
i
<
NUM
;
i
++
)
{
Ammo
.
destroy
(
vec
);
vec
=
new
Ammo
.
btVector3
(
4
,
5
,
6
);
}
Ammo
.
destroy
(
vec
);
assertEq
(
readMemoryCeiling
(),
memoryStart
,
"Memory ceiling must remain stable!"
);
for
(
var
i
=
0
;
i
<
NUM
;
i
++
)
{
vec
=
new
Ammo
.
btVector3
(
4
,
5
,
6
);
}
assertNeq
(
readMemoryCeiling
(),
memoryStart
,
"Memory ceiling must increase without destroy()!"
);
}
}
benchmark
();
return
benchmark
();
if
(
TEST_MEMORY
)
testDestroy
();
}
}
module
.
exports
=
stress
;
module
.
exports
=
stress
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment