Socket
Socket
Sign inDemoInstall

@indutny/bencher

Package Overview
Dependencies
16
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @indutny/bencher

Simple benchmarking tool


Version published
Weekly downloads
203
decreased by-41.33%
Maintainers
1
Install size
633 kB
Created
Weekly downloads
 

Readme

Source

@indutny/bencher

npm CI Status

Simple JavaScript benchmarking tool inspired by my bad understanding of how Criterion.rs works.

Disclaimer

Let's be honest, I'm terrible at statistics. This approach that I took here is probably incorrect, but the results appear to be stable enough so I'm happy to use it for my personal projects.

Any ideas on improving the algorithm are very welcome!

Installation

npm install -g @indutny/bencher

Usage

// benchmark.js
export const name = 'runner';

// Function to benchmark
export default () => {
  let sum = 0;
  for (let i = 0; i < 1e6; i++) {
    sum += i;
  }

  // Make sure to return a side-effect value (possibly a result of the
  // run) to ensure that the pure function calls are not optimized out by the
  // JIT compiler.
  return sum;
};
$ bencher benchmark.js
runner: 1’037.8 ops/sec (±18.8, p=0.001, n=98)

LICENSE

This software is licensed under the MIT License.

Keywords

FAQs

Last updated on 25 Dec 2022

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc