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

tinybench

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tinybench

A benchmarking library that supports high-resolution timers & returns statistically significant results.

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created

What is tinybench?

The tinybench npm package is a lightweight benchmarking tool for JavaScript. It allows developers to measure the performance of their code by running benchmarks and comparing the execution times of different code snippets.

What are tinybench's main functionalities?

Basic Benchmarking

This feature allows you to create a basic benchmark test. You can add multiple tests to the benchmark and run them to measure their performance.

const { Bench } = require('tinybench');

const bench = new Bench();

bench.add('Example Test', () => {
  // Code to benchmark
  for (let i = 0; i < 1000; i++) {}
});

bench.run().then(() => {
  console.log(bench.table());
});

Asynchronous Benchmarking

This feature allows you to benchmark asynchronous code. You can add tests that return promises and the benchmark will wait for them to resolve before measuring their performance.

const { Bench } = require('tinybench');

const bench = new Bench();

bench.add('Async Test', async () => {
  // Asynchronous code to benchmark
  await new Promise(resolve => setTimeout(resolve, 1000));
});

bench.run().then(() => {
  console.log(bench.table());
});

Customizing Benchmark Options

This feature allows you to customize the benchmark options such as the total time to run the benchmark and the number of iterations. This can help in fine-tuning the benchmarking process.

const { Bench } = require('tinybench');

const bench = new Bench({ time: 2000, iterations: 10 });

bench.add('Custom Options Test', () => {
  // Code to benchmark
  for (let i = 0; i < 1000; i++) {}
});

bench.run().then(() => {
  console.log(bench.table());
});

Other packages similar to tinybench

Keywords

FAQs

Package last updated on 29 Apr 2022

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