📝 Benchmark Benchmark
Build and run small JavaScript benchmarks in your browser — compare snippets with real timings.
📐 工作原理与说明
Throughput = operations × 1000 ÷ elapsed ms (ops/s); workloads: int 500 square-add loops, float trig/sqrt, str 100 concatenations, array push 200 items and sort, object write 200 keys. One operation differs by workload; the page shows raw elapsed time and ops/s only, with no cross-workload grading. Timing includes chunk scheduling but excludes the 30 ms start delay and optional warm-up.
对多个候选实现做可复现的性能对比,输出统计指标。
- 采样:每个候选重复运行 N 次,记录耗时,统计均值、中位数、标准差与百分位。
- 预热:先跑若干轮 warmup 让 JIT 完成优化再正式计时,避免冷启动偏差。
- 计时:用
performance.now()(单调高精度时钟)而非Date.now()。 - 干扰:浏览器后台节流、GC 停顿与其他标签页负载都会污染结果,应多轮取稳定值。
负载类型:
时长
预热
运行耗时
—
运算次数
—
性能(ops/sec)
—
💡 The page may briefly stutter while running. It shows raw elapsed time and ops/s only, with no unified threshold grading; workloads differ, so results are not comparable across workload types.