Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jonahsnider/benchmark

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jonahsnider/benchmark

A simple benchmarking library for Node.js.

  • 2.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
135
decreased by-18.18%
Maintainers
1
Weekly downloads
 
Created
Source

@jonahsnider/benchmark

A simple benchmarking library for Node.js.

Usage

import {Benchmark, csvReporter} from '@jonahsnider/benchmark';

// Create a benchmark
const benchmark = new Benchmark();

// Add different implementations to benchmark
benchmark.add('addition', () => 1 + 1 + 1);
benchmark.add('multiplication', () => 1 * 3);

// Run the benchmark with 3 trials
const results = await benchmark.exec(3);

// Use the CSV reporter to convert the results into valid CSV
// There are lots of other reporters too
console.log(csvReporter(results));

Reporters

Different reporters can be used to convert results into a different format. The library comes with several reporters you can use.

csv

Returns valid CSV following this format:

trial,title,duration_ms
0,addition,0.0079
1,addition,0.0012
2,addition,0.0006
0,multiplication,0.0051
1,multiplication,0.0003
2,multiplication,0.0002
import {csvReporter} from '@jonahsnider/benchmark';

console.log(csvReporter(results));
discord

Returns Discord compatible Markdown.

import {discordReporter} from '@jonahsnider/benchmark';

console.log(discordReporter(results));
markdown

Returns Markdown.

import {markdownReporter} from '@jonahsnider/benchmark';

console.log(markdownReporter(results));
table

Unlike other reporters that return a string, this reporter returns output designed for use with console.table.

import {tableReporter} from '@jonahsnider/benchmark';

console.table(table(results));

FAQs

Package last updated on 16 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc