This page documents how to add a benchmark on a practical level. If you're not an active developer on the benchmark, you'll probably be more interested in the Community Participation page.
<script src="../test.js"></script>. This script enables the test to run stand-alone or as part of the larger harness, as well as shadowing Math.random with a deterministic alternative.
testfunction defined in the global scope. All functions are passed the config argument defined in
setUp: Called to setup a run of the benchmark (a run consists of a number of calls to
tearDown: Called after a run of the benchmark has completed.
reset: Called after each time
testis called to reset for the next test.
test: The actual benchmark. Called repeatedly until enough runs have completed to get a statistically significant result.
Math.randomthe same number of times in each invocation of your
testfunction for the same config. The harness will run
testas many times as it deems necessary to minimize error and zero in the "true" performance of your test. If your test takes different amounts of time because of different return values from
Math.random, it will make it harder to zero in on the true value. The mocked
Math.random's seed is reset as often as necessary to ensure that--as long as you use
Math.randomthe same number of times for each call to
test--the behavior will be deterministic.
benchmarks.jsfor your benchmark.