1.3.0 • Published 2 years ago

@futoin/optihelp v1.3.0

Weekly downloads
13
License
Apache-2.0
Repository
github
Last release
2 years ago

NPM Version NPM Downloads Build Status stable

NPM

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

  1. 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.
  2. History of test results is stored under test/results in project root by default.
    • See OptiHelper dst_root option.
  3. Upon first run, only benchmark results are shown. This results are called "base".
  4. Upon any subsequent run, OptiHelper also shows different to "base" and "best" ever values.
  5. 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).
  6. Optional profiling uses v8-profiler module.
  7. The result is dumped in stdout, but an overall machine readable report is also generated.
  8. process.hrtime() with nanosecond resolution is used.

Usage

  1. Create optihelp.js in your tests folder with Suite of tests.
  2. Run the first ever cycle to get "base" results.
  3. Commit changes and the results.
  4. Create a branch of your project, for example optimization-refdata.
    • It would be helpful when you'll want to add extra tests.
  5. Make optimization and/or other changes
  6. 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 Helper

Kind: global class

new OptiHelper(name, options)

C-tor

ParamTypeDefaultDescription
namestringsuite name
optionsobjectvarious options
options.passinteger2how many passes to run
options.dst_rootstring"'test/results'"result history folder
options.test_timefloat5how long to run a single pass of each test in seconds
options.warmup_ratiofloat1how long to warmup based on test_time
options.profile_ratiofloat0.1how long to profile based on test_time
options.bench_delayfloat1benchmark delays after warmup
options.do_profilebooleanfalserun v8-profiler, if true
options.check_prodbooleantrueensure running in production env
options.report_filestringnullstore report in file, if true

optiHelper.test(name, cb) ⇒ OptiHelper

Execute test several times

Kind: instance method of OptiHelper
Returns: OptiHelper - self for chaining

ParamTypeDescription
namestringtest name
cbcallabletest callback

optiHelper.start(cb)

Start execution of tests

Kind: instance method of OptiHelper

ParamTypeDescription
cbcallablecompletion callback
1.3.0

2 years ago

1.2.5

4 years ago

1.2.4

4 years ago

1.2.3

5 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.9.1

7 years ago