You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

timeit-js

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

timeit-js

Simple Performance Measurement for Node.js

0.0.10
latest
Source
npmnpm
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

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})

Keywords

Time

FAQs

Package last updated on 04 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts