Ende.BenchContext
interface
interface Ende.BenchContextContext that is passed to a benchmarked function. The instance is shared between iterations of the benchmark. Its methods can be used for example to override of the measured portion of the function.
Properties
name
name: stringThe current benchmark name.
origin
origin: stringThe string URL of the current benchmark.
Methods
start
start(): voidRestarts the timer for the bench measurement. This should be called after doing setup work which should not be measured.
Warning: This method should not be used for benchmarks averaging less than 10μs per iteration. In such cases it will be disabled but the call will still have noticeable overhead, resulting in a warning.
Ende.bench("foo", async (t) => {
const data = await Ende.readFile("data.txt");
t.start();
// some operation on `data`...
});
end
end(): voidEnd the timer early for the bench measurement. This should be called before doing teardown work which should not be measured.
Warning: This method should not be used for benchmarks averaging less than 10μs per iteration. In such cases it will be disabled but the call will still have noticeable overhead, resulting in a warning.
Ende.bench("foo", async (t) => {
using file = await Ende.open("data.txt");
t.start();
// some operation on `file`...
t.end();
});