@marcosrv-ull/easybenchmarkjs
v1.0.10
Published
a light tool to benchmark functions in js
Downloads
1
Maintainers
Readme
easybenchmark.js
A really light tool to benchmark functions in js
Installation
For the package installation you only have to:
npm i @marcosrv-ull/easybenchmarkjs
Usage from code:
const easybenchmarkjs = require('@marcosrv-ULL/easybenchmarkjs');
const fastBench = easybenchmarkjs.fastBench;
The documentation of the function.
Examples
This is the main idea of the function:
const easybenchmarkjs = require('@marcosrv-ULL/easybenchmarkjs');
const fastBench = easybenchmarkjs.fastBench;
const myFunction = (whatEverAreTheParams) => {
// Do things
}
const TIMES_TO_BE_EXECUTED = 10;
let argumentA;
let argumentB;
.
.
.
let argumentN;
console.log(`Mean time elapsed with ${TIMES_TO_BE_EXECUTED} executions: ${easybenchmarkjs.fastBench(myFunction, [argumentA, argumentB, ..., argumentN], TIMES_TO_BE_EXECUTED)} ms`);
Output:
Mean time elapsed with 10 executions: <result_in_ms> ms
Author
marcosrv-ull
Tests
Execute:
npm run versions
mocha