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

benchly

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

benchly

A lightweight benchmarking library for synchronous and asynchronous functions.

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
0
Weekly downloads
 
Created
Source

benchly · license

A lightweight benchmarking library for measuring the performance of synchronous and asynchronous functions in JavaScript and TypeScript.

Installation

npm install benchly --save-dev
// or
yarn add benchly --dev

Usage

Synchronous Functions

import benchmark from 'benchly';

const syncFunction = () => {
  for (let i = 0; i < 1000; i++) {}
};

const result = benchmark(syncFunction, { iterations: 1000 });
console.log(`Time taken: ${result} ms`);

Asynchronous Functions

import benchmark from 'benchly';

const asyncFunction = async () => {
  await new Promise((resolve) => setTimeout(resolve, 10));
};

(async () => {
  const result = await benchmark(asyncFunction, { iterations: 100 });
  console.log(`Time taken: ${result} ms`);
})();

API

Parameters

  • fn: The function to benchmark.
  • options.iterations (optional): The number of iterations to run the benchmark. Default: 100.

Returns

  • The average time taken (in milliseconds) for the function to execute over the specified number of iterations.

License

MIT

Keywords

FAQs

Package last updated on 30 Nov 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