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

tinybench

Package Overview
Dependencies
Maintainers
3
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tinybench

[![CI](https://github.com/tinylibs/tinybench/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/tinylibs/tinybench/actions/workflows/test.yml) [![NPM version](https://img.shields.io/npm/v/tinybench.svg?style=flat)](https://www.npmjs.com

  • 3.0.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6M
decreased by-11.72%
Maintainers
3
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 02 Dec 2024

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