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

@mariocasciaro/benchpress

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mariocasciaro/benchpress

No fuss benchmarking

  • 0.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Synopsis

No fuss benchmarking for Node.js.

NPM

Build Status Dependency Status

Usage

var Benchpress = require('@mariocasciaro/benchpress');

var suite = new Benchpress({
  // iterations: 1000   <--- 1000 by default
});


suite
  .add('Benchmark name', {
    beforeAll: function() {
      // Run before the benchmark is started
    },
    beforeEach: function() {
      // Run before each iteration
    },
    fn: function() {
      // The code to profile
    },
    afterEach: function() {
      // Run after each iteration
    },
    afterAll: function() {
      // Run after the benchmark finishes
    }
  })
  .add('Async benchmark', function() {
    beforeAll: function(done) {
      // Run code asynchronously before the benchmark starts
      done();
    },
    fn: function(done) {
      // Profile async code too
      done();
    },
    afterEach: function(done) {
      // any function can be asynchronous...
      done();
    },
    //specify iterations per benchmark
    iterations: 300
  })
  //don't forget to run the suite!!!
  .run();

The code above will print in the console something like this:

Starting suite.
Benchmark 'Benchmark name': 374812 ops/sec (1000 iterations)
Benchpress 'Async benchmark': 126432 ops/sec (300 iterations)
Run complete.

Keywords

FAQs

Package last updated on 22 Aug 2023

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