About
FutoIn OptiHelp is Node.js module optimization helper.Unlike simple benchmark tools, FutoIn OptiHelp stores base and best results. It helps you to understand how new optimization and other changes affect performance of your project over time.
Documentation --> FutoIn Guide
Author: Andrey Galkin
Installation for Node.js
Command line:
$ npm install @futoin/optihelp --save
or:$ yarn add @futoin/optihelp --save
Concept & notes
- Tests are unique per CPU model and Node.js version.
- The combination is obfuscated with SHA-256 hash for minor security and ease of result management.
- History of test results is stored under
test/results
in project root by default.
- See OptiHelper `dst_root` option.
- Upon first run, only benchmark results are shown. This results are called "base".
- Upon any subsequent run, OptiHelper also shows different to "base" and "best" ever values.
- Benchmark sequence:
- calibration run (single shot),
- warmup run based on `test_time`*`warmup_ratio` options,
- actual benchmark for `test_time` option,
- after all tests are done, additional benchmark passes may run (`pass` option).
- Optional profiling uses
v8-profiler
module. - The result is dumped in stdout, but an overall machine readable report is also generated.
process.hrtime()
with nanosecond resolution is used.
Usage
- Create
optihelp.js
in your tests folder with Suite of tests. - Run the first ever cycle to get "base" results.
- Commit changes and the results.
- Create a branch of your project, for example
optimization-refdata
.
- It would be helpful when you'll want to add extra tests.
- Make optimization and/or other changes
- Run the
optihelp.js
test again and observe the results.
Examples
const optihelp = require('@futoin/optihelp');
optihelp('Suite Name', { test_time : 5, pass : 3 } )
.test( 'Async Test', (done) => { /* ... */; done() } )
.test( 'Sync Test', () => { /* ... */; } )
.start((report) => console.log(report));
API documentation
OptiHelper
Module Optimization HelperKind: global class
* [new OptiHelper(name, options)](#new_OptiHelper_new)
* [.test(name, cb)](#OptiHelper+test) ⇒ [<code>OptiHelper</code>](#OptiHelper)
* [.start(cb)](#OptiHelper+start)
new OptiHelper(name, options)
C-tor| Param | Type | Default | Description | | --- | --- | --- | --- | | name |
string
| | suite name |
| options | object
| | various options |
| options.pass | integer
| 2
| how many passes to run |
| options.dstroot | string
| "'test/results'"
| result history folder |
| options.testtime | float
| 5
| how long to run a single pass of each test in seconds |
| options.warmupratio | float
| 1
| how long to warmup based on testtime |
| options.profileratio | float
| 0.1
| how long to profile based on testtime |
| options.benchdelay | float
| 1
| benchmark delays after warmup |
| options.doprofile | boolean
| false
| run v8-profiler, if true |
| options.checkprod | boolean
| true
| ensure running in production env |
| options.reportfile | string
| null
| store report in file, if true |optiHelper.test(name, cb) ⇒ OptiHelper
Execute test several timesKind: instance method of
OptiHelper
Returns:
OptiHelper
- self for chaining| Param | Type | Description | | --- | --- | --- | | name |
string
| test name |
| cb | callable
| test callback |optiHelper.start(cb)
Start execution of testsKind: instance method of
OptiHelper
| Param | Type | Description | | --- | --- | --- | | cb |
callable
| completion callback |