BenchJS

Browser-based JavaScript benchmarking tool.
GitHub
114
Created 3 months ago, last commit 19 days ago
Number of contributors not available
69 commits
Stars added on GitHub, per day, on average
Yesterday
+1
Last week
+0.1
/day
Last month
+1.1
/day
npmPackage on NPM
benchjs
1.0.1
Monthly downloads on NPM
0
3
4
5
6
7
8
9
10
11
12
1
2
2024
2025
No dependencies
README

BenchJS

A browser-based JavaScript benchmarking tool: https://benchjs.com
Currently powered by benchmate.

screenshot

Features

  • 🚀 Zero Setup Required - Write and run benchmarks directly in your browser
  • 📊 Real-time Metrics - Watch your benchmarks run with detailed performance statistics
  • 🔄 Easy Comparison - Compare multiple implementations at once
  • 📋 Modern experience - TypeScript, Monaco, esbuild, all the goodies
  • 📦 ESM Package Support - Import packages directly via esm.sh
  • 🔗 Shareable Results - Share an URL to your benchmarks or an image of the results

Writing Benchmarks

File Structure

  • setup.ts: Setup code and shared utilities
  • implementations/*.ts: Implementation files containing benchmark code

Setup File

The setup file (setup.ts) is where you prepare data and create shared helpers. Everything you export will be available as a global for each implementation.

// Generate test data
export const generateData = (size: number) => {
  return Array.from({ length: size }, (_, i) => i);
};

// Export data and helpers
export const data = generateData(1000);
export const sum = (a: number, b: number) => a + b;

Implementation Files

Each implementation file must export a run function that contains the code you want to benchmark.

export const run = () => {
  // Your implementation here
  return data.reduce(sum, 0);
};

Using External Packages

BenchJS supports importing packages from esm.sh. Configure them on the settings page and then import them:

import { pick } from "lodash-es";

export const run = () => {
  return pick(data, ["id", "name"]);
};