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

high-score

v0.1.0

Published

Performance testing framework with history

Downloads

3,246

Readme

🥇 HighScore

Dependencies Node.js CI License

Performance testing framework with history

  • Automatically find benchmarks
  • Get "stable" results
  • Log benchmark history
  • Set a baseline to compare against

Installation

npm install --save-dev high-score

Quick Start

Make a benchmark like this:

const { benchmark } = require('high-score');

benchmark('my-fast-code', () => (
    // ... code to measure goes here
));

Run it from your terminal this:

high-score

Command Line Options

  -V, --version                    output the version number
  -c, --config <file>              Specify the benchmark config file (default: bench.config.js)
  --log-dir <dir>                  Specify the log directory (default: bench-log)
  -t, --include <pattern>          Runs only benchmarks matching a given regex
  --min-sample-duration <seconds>  Ensure that each sample takes at least this many seconds    
  --no-log                         Don't save the results to the log
  --set-baseline                   Mark these results as the "baseline" for future runs        
  -q, --quiet                      Prints only the results of the benchmarks (no progress)     
  -h, --help                       display help for command

Config File

You can set global benchmark options in a bench.config.js file at the root of your project. All settings are optional:

module.exports = {
    benchmarkPaths: ..., // glob for files that contain benchmarks (default: '**/*.bench.js')
    excludePaths: ...,   // glob for files to ignore (default: '**/node_modules/**')

    rootDir: ...,        // root directory to search for benchmarks (default: folder containing bench.config.js)
    logDir: ...,         // where to store logs of previous benchmark results (default: 'bench-log')

    moduleName: ...,     // name of module being tested (default: 'name' from package.json)
    moduleVersion: ...,  // version of module being tested (default: 'version' from package.json)

    timeout: ...,        // per-benchmark timeout in seconds (default: none)
};

API

Declare a benchmark using the benchmark() function:

    benchmark(<name>, <benchmark-function> [, <options>]);

The benchmark function is where you put the code you want to measure. It should take no arguments and return no result. A single "sample" of the benchmark may call the benchmark function many times.

The options object can have the following properties (all optional):

{
    minSampleDuration: ...,     // minimum time per sample, in seconds (default: 1)
    minSampleCount: ...;        // minimum number of samples to take (default: 8)
    maxSampleCount: ...;        // maximum number of samples to take or false for no limit (default: 32)
    timeout: ...;               // overall timeout in seconds, or false for no limit (default: false)

    confirmationHeuristic: ...; // settings for the confirmation heuristic, or false to disable it (see below)
    cooldownHeuristic: ...;     // settings for the cooldown heuristic, or false to disable it (see below)
    baselineHeuristic: ...;     // settings for the baseline heuristic, or false to disable it (see below)
}

Heuristics

To get stable benchmark results, HighScore uses a few heuristics to determine when to stop taking samples:

Confirmation

This heuristic causes HighScore to look for "confirmation" of a benchmark result, by taking samples until it has at least sampleCount samples within a certain variance.

This heuristic is on by default, and the default settings are:

    confirmationHeuristic: {
        sampleCount: 2,
        variance: 0.008,
    }

Which means it will keep running until it gets 2 additional samples within 1% of the best sample so far.

Cooldown

This heuristic tells HighScore to keep going for sampleCount more samples after the last best sample. This keeps it from ending the benchmark too soon if the samples are just starting to improve.

This heuristic is on by default, and the default settings are:

    cooldownHeuristic: {
        sampleCount: 3,
    }

Which means it will not stop the benchmark until it has collected 3 samples after the last best sample.

Baseline

If you have saved a baseline result for a benchmark, then this heuristic will tell HighScore to collect extra samples (up to sampleCount) if necessary to find one that is within a certain variance of the baseline result. This helps to avoid false reports that a benchmark has gotten slower.

This heuristic is on by default, and the default settings are:

    baselineHeuristic: {
        sampleCount: 32,
        variance: 0.01,
    }

Which means it will collect up to 32 samples until it gets one within 1% of the baseline result.