node-asm-benchmark
v0.0.4
Published
a webassembly benchmark in node
Downloads
14
Readme
node-asm-benchmark
Installation
use yarn
(the recommend way) to install as a dependency:
$ yarn add node-asm-benchmark
or npm
:
$ npm install --save node-asm-benchmark
Usage
import functions to your node to run benchmark:
benchmark = require("node-asm-benchmark");
// num indicates cal the nth item of fibonacci
// time indicates times of function being called
benchmark.runFibo(num, time);
we only offered fibonacci currently, and will support more benchmark options.
Example
index.js:
benchmark = require("node-asm-benchmark");
// calculate the 42nd Fibonacci for 5 times
benchmark.runFibo(42, 5);
console output:
$ node index
Calculating the 42th Fibonacci sequence using native js for 5 time(s)...
native js calculate spend 10.798s
average for 2.1596s
Start reading from wasm source file ...
reading wasm source file spend 0.0019999999999988916s
Start compiling wasm source file ...
compiling wasm source file spend 0.0030000000000001137s
Calculating the 42th Fibonacci sequence using web assembly for 5 time(s)...
webassembly calculate spend 8.325999999999999s
average for 1.6651999999999998s