npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

benchmarkjs-helper

v1.0.1

Published

Add setupEach and better output to benchmark.js for node

Readme

Benchmark.js helper for node

What it does

It is a very simple wrapper around benchmark.js and more specifically the Benchmark.Suite with the following additional functionality.

  • Adds support for pre run setup for each iteration of a test
  • Uses beautify-benchmark to produce nicer output and status updates
  • Throws on error halting the benchmark

Installation

npm install --save-dev benchmarkjs-helper

Usage

Pass an object containing the test functions you wish to benchmarkjs-helper and it will handle passing them to benchmark.js and creating useful console output of the results. The keys are used as the name for the test in the report that is created.

const benchIt = require('benchmarkjs-helper')

benchIt({
	add: () => {
		return 1 + 1
	},
	subtract: () => {
		return 1 - 1
	},
	multiply: () => {
		return 1 * 1
	},
	divide: () => {
		return 1 / 1
	},
})

Run it from the command line/terminal:

node examples/simple.js

Outputting something like the following except it is colourised (colorized) for easier reading by beautify-benchmark.

  4 tests completed.

  add      x 717,864,803 ops/sec ±1.87% (83 runs sampled)
  subtract x 721,117,181 ops/sec ±1.81% (82 runs sampled)
  multiply x 791,720,133 ops/sec ±0.65% (97 runs sampled)
  divide   x 757,457,709 ops/sec ±1.66% (85 runs sampled)

In this case multiply is the winner and would be highlighted in green.

setupEach()

You can do some up front work to seed each function with its own data set without affecting the benchmark. This is useful for tests like the one in examples/setupEach/setupEach.js where you only want to test one aspect of a data structure (deletion) and not the initial creation. Your application could be delete heavy.

To use this feature you would define the object passed to benchmarkjs-helper slightly differently (it is important that setupEach is given a full JavaScript function and not an arrow function as this is used internally):

benchIt({
	add: {
		setupEach: () => {
			return [1, 1] // becomes x in `fn` below
		},
		fn: x => {
			return x[0] + x[1] // evaluates to 1 + 1
		},
	},
	multiply: {
		setupEach: () => {
			return [1, 1] // becomes x in `fn` below
		},
		fn: x => {
			return x[0] * x[1] // evaluates to 1 * 1
		},
	},
})

Credits

Mostly this project does nothing and all the real work is done by:

Licence

Apache 2.0