Benchmarks for runtime type validation libraries.
| 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 |
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
# 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 devOpen http://localhost:5173 — select a runtime, toggle valid/invalid, filter by test type.
- Create a directory:
src/modules/schema/cases/<slug>/ - Add
meta.json:
{
"package": "my-lib",
"npm": "https://www.npmjs.com/package/my-lib",
"github": "https://github.com/user/my-lib"
}- (Optional) Add build.ts to compile the library.
- Add
index.ts— callcreateCase()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;
}
});- Run test for check output is correct:
npm run test