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

Performance Measuring for Node JS

0.0.7
Source
npmnpm
Version published
Maintainers
1
Created
Source

timeit-js

Simple Node Performance Measurement

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
eFunction Executions1000
rTest repetitions1
lShow 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: 2})

Keywords

Time

FAQs

Package last updated on 03 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