1.0.5-rc.19 • Published 8 months ago

@digigov/benchmark v1.0.5-rc.19

Weekly downloads
-
License
BSD-2-Clause
Repository
-
Last release
8 months ago

@digigov/benchmark

@digigov/benchmark is a lightweight utility to assist with the profiling of JavaScript code, offering insights into execution time and memory usage during benchmark runs. Performance is measured by running the code for a specified amount of iterations, and calculating the average operations per millisecond and memory usage per millisecond.

Features

  • Simple and configurable benchmark setup
  • Customizable iteration and concurrency settings for benchmarks
  • Support for async benchmarks
  • Detailed profiling report, with execution time (in milliseconds) and memory usage metrics

Installation

npm install @digigov/benchmark

Usage

  1. Initialization
import BenchmarkProfiler from '@digigov/benchmark';

const profiler = new BenchmarkProfiler({
  iterations: 1000, // optional
  concurrency: 1, // optional
});
  1. Adding benchmarks
profiler.add({
  name: 'Name of the benchmark',
  fn: async () => {
    // Benchmark code
  },
  beforeAll: async () => {
    // Optional. Runs once before all iterations
  },
  afterAll: async () => {
    // Optional. Runs once after all iterations
  },
  beforeEach: async () => {
    // Optional. Runs before each iteration
  },
  afterEach: async () => {
    // Optional. Runs after each iteration
  },
});
  1. Running benchmarks
const results = await profiler.run();
console.log(results);

Result Structure

Results from the run() function return an array with each benchmark's result:

[
  {
    name: string, // Name of the benchmark
    iterations: number, // Number of iterations run
    timeInMs: number, // Total time taken for all iterations in milliseconds
    averageOpsPerMs: number, // Average operations per millisecond
    averageKbPerMs: number, // Average memory used per millisecond
    maxKb: number, // Peak memory usage during the benchmark run
  },
];
1.0.5-60d81ed8

8 months ago

1.0.5-b4cd6916

9 months ago

1.0.5-rc.19

9 months ago

1.0.5-36b707c1

9 months ago

1.0.5-daaf7bdf

9 months ago

1.0.5-113e6661

10 months ago

1.0.5-6e3977bc

9 months ago

1.0.5-0edebf87

1 year ago

1.0.5-f0a886ce

11 months ago

1.0.5-d57821ba

11 months ago

1.0.5-rc.17

12 months ago

1.0.5-rc.18

10 months ago

1.0.5-6c42d5eb

11 months ago

1.0.5-2445d5cb

11 months ago

1.0.5-85c27c19

11 months ago

1.0.5-rc.13

1 year ago

1.0.5-rc.14

1 year ago

1.0.5-rc.15

1 year ago

1.0.5-rc.16

1 year ago

1.0.5-rc.10

1 year ago

1.0.5-rc.11

1 year ago

1.0.5-rc.12

1 year ago

1.0.4

1 year ago

1.0.4-fd2cea11

1 year ago

1.0.2

1 year ago

1.1.0

1 year ago

1.0.3

1 year ago

1.1.0-2a507fd6

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

1.0.0-rc.5

2 years ago

1.0.0-rc.6

2 years ago

1.0.0-23c81d9f

2 years ago

1.0.0-51c931ab

2 years ago

0.1.0-47312a12

2 years ago

0.1.0-b0737a96

2 years ago

0.1.0-rc.4

2 years ago

0.1.0-8b33e4c8

2 years ago

0.1.0-b4257f67

2 years ago

0.1.0-a131264d

2 years ago

0.1.0-ab30975f

2 years ago

0.1.0-e322b0cc

2 years ago

0.1.0-05af31dd

2 years ago

0.1.0-00643e1d

2 years ago

0.1.0-eb2842b4

2 years ago

0.1.0-rc.3

2 years ago

0.1.0-8bbf3ef2

2 years ago

0.1.0-rc.2

2 years ago

0.1.0-rc.1

2 years ago