Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

function-benchmark-util

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

function-benchmark-util

A library to benchmark javascript functions.

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

JavaScript Function Benchmark Utility

GitHub npm type definitions

A library to benchmark JavaScript functions with microsecond precision.

Docs | Github | NPM

Install

npm i function-benchmark-util -D

Usage

import { benchmark, benchmarkTimes } from 'function-benchmark-util';

function someFunction(param1, param2) {
    // Does something
};

const result1 = benchmark(someFunction, ['param1', 'param2']);

// Running multiple iterations
const result2 = benchmarkTimes(someFunction, 10, ['param1', 'param2']);
// See the results
console.table([result1, result2]);

BenchmarkResult object

All benchmark functions, including benchmark, benchmarkTimes, benchmarkWithThis,benchmarkTimesWithThis return a BenchmarkResult object.

FieldDescription
functionNamestring Name of the executed function
runCountnumber Execution count passed to benchmarkTimes and benchmarkTimesWithThis functions.
minnumber Minimum duration scored in microseconds
maxnumber Maximum duration scored in microseconds
averagenumber The average duration of all executions in microseconds
fnReturnsany Latest returned function result during execution(s)

this context

Intentionally benchmark and benchmarkTimes functions set this context of the executed function to null to avoid ambiguity.

If you need to set this, use benchmarkWithThis and for multiple executions, use benchmarkTimesWithThis.

For more, see the documentaion and examples.

License

MIT © Cengiz Can

David David npm bundle size

Keywords

FAQs

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc