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

speed.js

v0.1.7

Published

A quick rudimentary speed test for algorithms

Downloads

12

Readme

speed.js

A quick rudimentary console speed/benchmark test for algorithms

  • create multiple speed tests in a snap
  • run all tests at once
  • output test results to console and file
  • runs warmup round internally
const Speed= require( 'speed.js' );

// create an instance with specific settings
const test= new Speed({
	rounds	: 3,		// 3 rounds
	calls	: 10000000,	// 10.000.000 function calls per round
	details	: false		// set true to show details for each round
	file	: './speed.log'	// write log output also to file(optional)

});

// add some tests
test
	// you can add a names/id for a test	
	.add( 'create Object instances', () => new Object() )
	.add( 'create Object literals', () => {} )
	// or add an anonymus test	
	.add( () => 24 * 1.75 );

// run them all
test.run();
// *speed.js* - running 3 tests.. 

// 1: create Object instances: 3 rounds of 10.000.000 calls..
// average time for  10.000.000 calls :     82 ms
// total time for    30.000.000 calls :    246 ms

// 2: create Object literals: 3 rounds of 10.000.000 calls..
// average time for  10.000.000 calls :     50 ms
// total time for    30.000.000 calls :    150 ms

// 3: anonymus: 3 rounds of 10.000.000 calls..
// average time for  10.000.000 calls :     54 ms
// total time for    30.000.000 calls :    163 ms

// done! test results have been saved to: ./speed.log

Actual milliseconds elapsed are system and setup specific of course.


node.js

Install with npm: npm install speed.js


disclaimer

speed.js is not a 100% accurate and scientific benchmark tool for everything Javascript. It is just a quick rudimentary test-tool to help you compare the running speed of different algorithms while optimizing for speed.

For more advanced testing I'd recommend benchmark.


Speed

Speed.details

<boolean> Speed.details

Set to show measurements for every round. This is a global fallback setting, defaults to false.


Speed.rounds

<number> Speed.rounds

This is a global fallback setting, defaults to 1.


Speed.calls

<number> Speed.calls

This is a global fallback setting, defaults to 1.


Speed.maxCalls

<number> Speed.maxCalls

This is a global fallback setting.

Defaults to 100.000.000 function calls. Can be set to any value, to prevent accidently launching a test that could take hours to complete or hang your system..


Speed.warmupCycles

<number> Speed.warmupCycles

Defaults to 1.000.000 cycles.


Speed.run

<function> Speed.run( callback, calls, rounds, details, name= 'anonymus' )

The static method available, can instanlty run a test.

Speed.run( 
	() => new String( "Any callback for speed testing" ),
	100000,
	8
);

prototype


Speed.prototype.constructor

<function> constructor( <object> settings )

.rounds, .calls and .details can be pre-set via settings.


Speed.prototype.callbacks

<object> callbacks

An object holding all functions added with .add or .run


Speed.prototype.rounds

<number> rounds


Speed.prototype.calls

<number> calls


Speed.prototype.details

<boolean> details


Speed.prototype.add

<function> add( name= 'anonymus', callback )

Adds a function to the tests


Speed.prototype.run

<function> run( name= 'anonymus', callback )

Runs all functions set with .add. If name and/or callback is set, .run will override the already added functions, not running them. This can come in handy if you have some tests set up, and you want to do some quick manual test apart from the others.

const speed= new Speed();

speed.run( function(){
	const thisThing= 'inhibiting the other tests..';
}, 1000000, 5);


change log

0.1.5

  • adds log file option
  • adds babel transpiler stage for more stable build
  • use last update of dependency
  • adds test script, run with: npm run test
  • update readme

0.1.0

Initial commit.


additional

I am always open for feature requests or any feedback. You can reach me at Github.