Skip to content

SX-3/perfcheck

Repository files navigation

Benchmarks for runtime type validation libraries.

Website

Test cases

Type Valid Invalid
parseSafe Parses and returns cleaned data Throws on invalid
parseStrict Like safe, but rejects unknown keys Throws on unknown keys
assertLoose Returns true without parsing Throws on invalid
assertStrict Returns true, rejects extra keys Throws on invalid or extra keys

Score

The score is the normalized geometric mean of valid tests — the industry standard for benchmarking (used by SPEC CPU, Phoronix, AnandTech). Each test contributes equal weight.

  • Library with the highest geomean → 100
  • Others scaled proportionally
  • Bars show operations per second (higher = better)
  • Margin (±%) is the 95% confidence interval

Quick start

# Install
npm install

# Run benchmarks
bun run schema:run:bun   # Bun
npm run schema:run       # Node (via tsx)

Results are saved to src/modules/schema/results/ as per-platform gzipped JSON files.

# Dev server
npm run dev

Open http://localhost:5173 — select a runtime, toggle valid/invalid, filter by test type.

Adding a library

  1. Create a directory: src/modules/schema/cases/<slug>/
  2. Add meta.json:
{
  "package": "my-lib",
  "npm": "https://www.npmjs.com/package/my-lib",
  "github": "https://github.com/user/my-lib"
}
  1. (Optional) Add build.ts to compile the library.
  2. Add index.ts — call createCase() for each scenario:
import { createCase } from '../../benchmarks/case.ts';
import { parse, assert } from 'my-lib';

createCase('parseSafe', () => {
  return (data) => parse(data)
});
createCase('parseStrict', () => {
  return (data) => parse(data, { strict: true })
});
createCase('assertLoose', () => {
  return (data) => { 
    assert(data);
    return true;
  }
});
createCase('assertStrict', () => {
  return (data) => { 
    assert(data, { strict: true });
    return true;
  }
});
  1. Run test for check output is correct: npm run test

About

Benchmarks for runtime type validation libraries.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages