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 🙏

© 2024 – Pkg Stats / Ryan Hefner

rollingroad

v1.1.0

Published

A tiny and extremely simple Javascript tool for benchmarking functions against one-another.

Downloads

2

Readme

The Rolling Road Javascript library

This is a very simple benchmarking tool for comparing Javascript functions against one-another.

The repo contains examples both in the browser (browser-example.html) and in node (run node node-example.js).

Dependencies

Rolling Road has a dependency on dinqyjs which must be at least version v1.2.0. You can find this library on Github too, which itself has no dependencies.

Usage

The .withOptions part of the code is optional. Without these defaults will be used.

Each sample loops over the function repeatedly (which you can adjust by specifying iterations). At the end of the sample the tool checks how many milleseconds have passed.

For simple functions a large number of iterations compared to samples is preferable. For more complex functions fewer iterations are necessary to get meaningful results.

The interquartile is used to stop the statistics being skewed by outliers using a pretty crude but effective approach. The value of 0.5 supplied here tells the tool to throw away the top and bottom 25% of results from a sample and keep the middle 50%. Choose a value between 0 and 1. A small value will give more accurate results, but is wasteful. A good guide is to benchmark the same function and ensure the outputs are roughly equal.

new RollingRoad({ test: function1, name : 'function1' }, { test: function2, name : 'function2' })
	.withOptions( { iterations : 1000000, samples : 50, interquartile : 0.5 })
	.run()
	.done(function(results) {
		console.log(results[0].name
			+ '. samples: ' + results[0].samples
			+ ' duration: ' + results[0].duration
			+ ' median: ' + results[0].median
			+ ' average: ' + results[0].average);

		console.log(results[1].name
			+ '. samples: ' + results[1].samples
			+ ' duration: ' + results[1].duration
			+ ' median: ' + results[1].median
			+ ' average: ' + results[1].average);
});

Results

3 metrics are offered in the resultset for each test case. The total duration of all samples combined, the median duration each sample took to run and the average time each sample took to run.

Results should only be taken as a guide and may differ from machine to machine.