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

benchmartian

v0.0.2

Published

Benchmark.js mocha like command line interface

Downloads

19

Readme

Benchmartian

Run Javascript benchmarks from the CLI

Benchmartian allows you to run your incredible [benchmark.js][http://benchmarkjs.com] benchmarks from the command line much like you would any other test suite such as mocha.

Install

Install from npm.

$ npm install -g benchmartian

And to run benchmarks:

$ benchmartian

Benchmarking benchmarks/benchmarks.js..
..
Completed file benchmarks/benchmarks.js.

Results
-> benchmarks/benchmarks.js
    RegExp#test x 15,634,369 ops/sec ±0.96% (94 runs sampled)
    String#indexOf x 25,131,771 ops/sec ±0.97% (95 runs sampled)

Simple as.

Usage

Benchmartian will take an array of files as arguments or if no arguments are given, benchmartian will look in benchmark/ directory of current working directory. You can also supply a reporter which will define how the test results are outputted. To see a list of reporters do benchmartian --reporters.

benchmartian -- Run benchmark.js benchmarks from the CLI.

Usage:
  benchmartian [files]     Begin benchmarking. If no are files supplied, benchmartian looks in `benchmark/`.
  --reporter [reported]    Select a reporter from /reporters. Defaults to basic.
  --reporters              Print out available reporters.
  --help                   Print this help.

Benchmarks

To make defining benchmarks incredibly simple, benchmartian exposes all methods on the benchmark.Suite prototype into the global scope which allows for concise definitions. The only function benchmartian calls (if it hasn't already been called with your own options) is suite.run. The reporters take care of handling the output so you can sit back and focus on your benchmarks.

Example from the benchmarkjs.com homepage.

add('RegExp#test', function() {
  /o/.test('Hello World!');
});

add('String#indexOf', function() {
  'Hello World!'.indexOf('o') > -1;
});

Example defining your own run options:

add('RegExp#test', function() {
  /o/.test('Hello World!');
});

add('String#indexOf', function() {
  'Hello World!'.indexOf('o') > -1;
});

options.maxTime = 3; // Second

Since benchmark.Suite is exposed, you can configure how the benchmarks are run by supplying options to the run function or set them on the global options variable. For the options documentation, see here.

Reporters

Reporters for benchmartian are made incredibly easy by the benchmark.js library. To begin, create a Javascript file by the name of your reporter in the reporters/ directory and require the index.js file. See reporter/basic.js for an example.

	var reporter = require("./");

The reporter's job is to handle different events emitted by benchmartian and a benchmark.Suite on a suite. benchmartian emits 3 events:

  • begin with the (files) as an argument.
  • file with (filename, suite). It's in this callback where you define your benchmark.Suite events.
  • complete with (results). Results is a key value store of filename: suite so you can compile a comphrensive report.

Finally, export your reporter:

	module.exports = reporter;

Thanks

Thanks to the authors of the incredible benchmark.js library. benchmartian owes it's existance to it.

License

MIT