BenchmarkJS
A easy benchmark framework for Javascript code.
Installation
Installing with npm:
$ npm install benchmarkjs --save-dev
This module don't have dependencies.
Usage
In a browser:
In Node.js:
var Benchmark = ;
Enable Node.js V8 native syntax for optimization check with this parameter:
node --allow-natives-syntax
Usage example:
var benchmarkjs = ; benchmarkjsoptions testTime: 4000; var bigArray1 = 1000;; var bigArray2 = 1000;; console;
The result is similar to this:
name: 'n < max' // test name elapsed: 4395 // total time to test checks: 2 // internal time checks totalIterations: 484811 // total executions persecondIterations: 110309 // execution per second isOptimized: null // have value only with node and the paramenter --allow-natives-syntax diff: '0%' // difference with the best case name: 'n < hugeArray2.length' // test name elapsed: 4325 // total time to test checks: 2 // internal time checks totalIterations: 475535 // total executions persecondIterations: 109950 // execution per second isOptimized: null // have value only with node and the paramenter --allow-natives-syntax diff: '0.33%' // difference with the best case
isOptimized can have these values:
1 - "optimized"2 - "not optimized"3 - "always optimized"4 - "never optimized"6 - "maybe deoptimized"7 - "turbofan optimized"
Contributor
- Pablo Almunia (github:pabloalmunia or @pabloalmunia)