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

benchmark-node

v0.7.3

Published

A Node.js benchmarking library for accurate performance test.

Downloads

45

Readme

benchmark-node

Node.js benchmarking library for accurate performance testing.

Part of the design reference BenchmarkDotNet.

Usage

It's easy to write benchmarks.

import { BenchmarkJob, Column, Params } from 'benchmark-node';
import crypto from 'crypto';

let buffer: Buffer;

new BenchmarkJob({ columns: [Column.Median, Column.Min, Column.Max, Column.Ops] })
    .setSetup(
        (size: number) => {
            buffer = crypto.randomBytes(size);
        },
        [new Params(1000, 10_000)],
    )
    .add('md5', () => crypto.createHash('md5').update(buffer).digest('hex'))
    .add('sha1', () => crypto.createHash('sha1').update(buffer).digest('hex'))
    .add('sha256', () => crypto.createHash('sha256').update(buffer).digest('hex'))
    .add('sha384', () => crypto.createHash('sha384').update(buffer).digest('hex'))
    .add('sha512', () => crypto.createHash('sha512').update(buffer).digest('hex'))
    .run();

benchmark-node will run the benchmarks, aggregates the measurements and print a summary table.

BenchmarkNode v0.7.2, Windows 10.0.22000
AMD Ryzen 7 5800H with Radeon Graphics, 1 CPU, 16 logical and 8 plysical cores
Node.JS 16.13.0 (V8 9.4.146.19-node.13)

| Function |  size |      Mean |     Error |    StdDev |    Median |       Min |       Max |    Op/s |
|---------:|------:|----------:|----------:|----------:|----------:|----------:|----------:|--------:|
|      md5 |  1000 |  2.637 us | 0.0277 us | 0.0499 us |  2.648 us |  2.564 us |  2.727 us | 379,279 |
|     sha1 |  1000 |  1.796 us | 0.0163 us | 0.0295 us |  1.799 us |  1.729 us |  1.848 us | 556,839 |
|   sha256 |  1000 |  1.874 us | 0.0363 us | 0.0655 us |  1.892 us |  1.786 us |  2.033 us | 533,478 |
|   sha384 |  1000 |  2.553 us | 0.0256 us | 0.0462 us |  2.564 us |  2.475 us |  2.635 us | 391,714 |
|   sha512 |  1000 |  2.570 us | 0.0395 us | 0.0714 us |  2.578 us |  2.472 us |  2.714 us | 389,091 |
|      md5 | 10000 | 12.984 us | 0.1017 us | 0.1836 us | 13.005 us | 12.556 us | 13.302 us |  77,019 |
|     sha1 | 10000 |  5.952 us | 0.0375 us | 0.0678 us |  5.963 us |  5.775 us |  6.084 us | 168,015 |
|   sha256 | 10000 |  6.307 us | 0.0344 us | 0.0621 us |  6.285 us |  6.235 us |  6.477 us | 158,564 |
|   sha384 | 10000 | 12.109 us | 0.1626 us | 0.2937 us | 12.092 us | 11.764 us | 12.978 us |  82,584 |
|   sha512 | 10000 | 12.126 us | 0.1664 us | 0.3005 us | 12.102 us | 11.798 us | 12.790 us |  82,468 |

For more usages, check:

Development

Execute npm run build or yarn build to build this project.

Execute npm run dev to watch the building.

Execute npm run test or npm run test-full to do unit test.

Execute npm run build-test or yarn build-test to build both source code and test code, then can run js files in folder dist/test to view the output of benchmarking.