mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-25 07:02:13 +00:00
Improve n-body bench env (#457)
This commit is contained in:
parent
8d2194f045
commit
206e4c4565
@ -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___
|
||||
|
@ -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",
|
||||
|
@ -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));
|
||||
|
Loading…
x
Reference in New Issue
Block a user