Provide a simple interface for testing how fast different methods are.
Installation
npm install timeit
or
git clone git@github.com:my8bird/nodejs-timeit.git
npm install
Usage
Test one method
var timeit = iterations = 30000; { var a = 'a string' b = a; ;} timeit
Compare to approaches to see which is faster
var timeit = iterations = 30000; { var a = 'a string' b = a; ;} { var a = 'a string' b = a + 'stuck together'; ;} timeit;
Example Compare Output
Baseline { total_runtime: 151,
total_step_runtime: 28,
average_step_runtime: 0.0009333333333333333 }
Concat speed { total_runtime: 149,
total_step_runtime: 36,
average_step_runtime: 0.0012,
total_off_baseline: -2,
total_step_off_baseline: 8,
average_step_off_baseline: 0.00026666666666666657 }
Using Plus speed { total_runtime: 141,
total_step_runtime: 44,
average_step_runtime: 0.0014666666666666667,
total_off_baseline: -10,
total_step_off_baseline: 16,
average_step_off_baseline: 0.0005333333333333334 }
TODO
Be able to test parallell execution as well as serial. This is important when comparing to methods where one is async and the other is not.