Socket
Book a DemoInstallSign in
Socket

bench-cli

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bench-cli

An easy-to-use CLI for running benchmarks

latest
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

Bench-CLI

Build Status npm version

Bench-CLI is an easy-to-use CLI for running benchmarks.

Installation

npm install -g bench-cli

Running Benchmarks

Running benchmarks is designed to be super simple and easy. You simply specify a path to the directory where your benchmark scenarios are located and then the number of iterations to run for each scenario.

bench <directory> --iterations <number>

If you don't specify a directory, the command will default to bench, relative to your current working directory.

Defining Benchmarks

Benchmarks are defined by creating a simple object export, known as a Bench. Each Bench defines a scenario function which represents the code to be benchmarked. They can optionally define several hooks which allow for setup and cleanup before and after runs.

module.exports = {
  // [Optional] Runs once before all of the scenario iterations
  setup() {},

  // [Optional] Runs once before each of the scenario iterations
  beforeScenario() {},

  // The benchmark scenario for which time is recorded
  scenario() {},

  // [Optional] Runs once after each of the scenario iterations
  afterScenario() {},

  // [Optional] Runs once after all of the scenario iterations
  cleanup() {}
};

Each of the above hooks, including scenario, is invoked with a context object that is empty by default. This allows information to be shared between the hooks, without having to rely on module state.

You can only define one scenario per Bench and, thus, per file. This limitation is in place to encourage isolation of benchmarking scenarios to help guarantee that you are getting accurate results.

FAQs

Package last updated on 10 Feb 2017

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.