MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / bench

Function bench

test/big-decimal/benchmarks.ts:4–15  ·  view source on GitHub ↗
(name: string, fn: () => void, iterations = 1000)

Source from the content-addressed store, hash-verified

2import { Decimal } from 'decimal.js';
3
4function bench(name: string, fn: () => void, iterations = 1000): string {
5 // Warmup
6 for (let i = 0; i < 10; i++) fn();
7
8 const start = performance.now();
9 for (let i = 0; i < iterations; i++) fn();
10 const elapsed = performance.now() - start;
11 const msPerOp = elapsed / iterations;
12 const line = ` ${name.padEnd(30)} ${msPerOp.toFixed(4)} ms/op (${iterations} iters)`;
13 console.log(line);
14 return line;
15}
16
17console.log('BigDecimal vs Decimal.js Benchmarks');
18console.log('='.repeat(70));

Callers 1

benchmarks.tsFile · 0.70

Calls 3

fnFunction · 0.85
toFixedMethod · 0.80
logMethod · 0.65

Tested by

no test coverage detected