Improve n-body bench env (#457)

This commit is contained in:
Max Graey 2019-02-21 03:14:35 +02:00 committed by Daniel Wirtz
parent 8d2194f045
commit 206e4c4565
3 changed files with 24 additions and 9 deletions

View File

@ -31,17 +31,17 @@ Benchmark
***Environment:***
- MacBook Pro (Retina, 15-inch, Late 2013)
- macOS 10.14
- node.js v10.11.0
- rustc 1.31.0-nightly (4bd4e4130 2018-10-25)
- macOS 10.14.3
- node.js v11.9.0
- rustc 1.33.0-nightly (ceb251214 2019-01-16)
***Results:***
| Target | Time, ***ms*** | Size, ***KB*** |
|-------------------------|-----------------|----------------|
| **AssemblyScript WASM** | **3167** | **2** |
| AssemblyScript ASMJS | 3633 | 21* |
| JavaScript | 2628 | 5* |
| Rust WASM | 3876 | 13 |
| **AssemblyScript WASM** | **2901** | **2** |
| AssemblyScript ASMJS | 3720 | 19* |
| JavaScript | 2716 | 5* |
| Rust WASM | 2883 | 13 |
___* unminified___

View File

@ -10,7 +10,7 @@
"tsbuild": "tsc -p assembly -t ES2017 -m commonjs --outDir build",
"build": "npm run asbuild && npm run tsbuild",
"server": "http-server . -o -c-1",
"test": "node tests"
"test": "node --noliftoff --nowasm-tier-up --wasm-lazy-compilation --wasm-no-bounds-checks --expose-gc tests"
},
"devDependencies": {
"http-server": "^0.11.1",

View File

@ -34,11 +34,25 @@ const nbodyJS = new Function(
...Object.keys(scopeJS).concat(src + "\nreturn exports"))(...Object.values(scopeJS)
);
function gcCollect() {
if (global.gc) {
global.gc();
global.gc();
}
}
function sleep(delay) {
var start = Date.now();
while (Date.now() < start + delay);
}
function test(nbody, steps) {
nbody.init();
var start = process.hrtime();
nbody.bench(steps);
return process.hrtime(start);
let t = process.hrtime(start);
gcCollect();
return t;
}
var steps = process.argv.length > 2 ? parseInt(process.argv[2], 10) : 20000000;
@ -66,6 +80,7 @@ prologue("Rust WASM", steps);
epilogue(test(nbodyRS, steps));
console.log("\nWARMED UP SERIES:\n");
sleep(1000);
prologue("AssemblyScript WASM", steps);
epilogue(test(nbodyAS, steps));