0.0.10 • Published 4 years ago

timeit-js v0.0.10

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

timeit-js

Simple Performance Measurement for Node.js

Measure the average execution time of a function. If you find any bugs or have suggestions feel free to help and fork the package.

Installation

npm i timeit-js

Import

const timeit = require('timeit-js')

Timeit Function

/**
 * Measure the average execution time of a function
 * @param {Function} fn A function for performance measurement
 * @param {Array} args Function arguments
 * @param {Object} options
 * @returns {Number} Result in milliseconds
 */
timeit(fn, args=[], options={})

Options

ParameterOptionDefault
eNumber of function executions1000
rNumber of test repetitions1
lShow timeit-result in logstrue
dNumber of decimals in Logging text6

Example

const timeit = require('timeit-js')

function sum () {
  return [...arguments].reduce((p, c) => p+c, 0)
}

timeit(sum, args=[1, 2, 3, 4], options={e: 100000, r: 100, d: 6})
0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago