new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Deno · Reference · all subjects

runtime api/bench

9 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Deno.bench() API function definition forms

The Deno.bench() API supports multiple forms: (1) Compact form with name and function: Deno.bench("name", () => {}); (2) Compact form with named function: Deno.bench(function name() {}); (3) Longer form with object definition: Deno.bench({ name: "name", fn: () => {} }); (4) Compact form with configuration object: Deno.bench("name", { permissions: { read: true } }, () => {}); (5) Longer form with object and function: Deno.bench({ name: "name", permissions: { read: true } }, () => {}); (6) Longer form with object and named function: Deno.bench({ permissions: { read: true } }, function name() {}).

Deno.bench() async functions

The Deno.bench() API supports asynchronous benchmark functions by passing an async function that returns a promise. Example: Deno.bench("async hello world", async () => { await 1; });

Deno.BenchContext.start() and end() methods

The Deno.BenchContext provides start() and end() methods to define critical sections of code that should be measured in a benchmark. Code outside the section between these calls is excluded from measurement, allowing setup and teardown code to be excluded from timing. Example: b.start(); await new Response(file.readable).arrayBuffer(); b.end();

Deno.BenchDefinition.group option

The `group` option in Deno.BenchDefinition assigns a benchmark to a group for comparison purposes. Example: Deno.bench("url parse", { group: "url" }, () => { new URL("https://deno.land"); });

Deno.BenchDefinition.baseline option

The `baseline` option in Deno.BenchDefinition marks a benchmark case as a baseline for comparison against other cases in the same group. Example: Deno.bench("Date.now()", { group: "timing", baseline: true }, () => { Date.now(); });

Deno.BenchDefinition.ignore option

The `ignore` option in Deno.BenchDefinition is a boolean that, when set to true, skips the bench. Example: Deno.bench({ name: "bench windows feature", ignore: Deno.build.os !== "windows", fn() {} });

Deno.BenchDefinition.only option

The `only` option in Deno.BenchDefinition, when set to true, runs only benchmarks with this option set. Multiple benchmarks can have this option. The overall benchmark run will fail if any bench is flagged with `only`, as this is a temporary measure for debugging that disables most other benchmarks.

deno bench example with critical sections

Example benchmark with critical sections: Deno.bench("foo", async (b) => { using file = await Deno.open("a_big_data_file.txt"); b.start(); await new Response(file.readable).arrayBuffer(); b.end(); }); This benchmark requires the --allow-read flag to run: deno bench --allow-read file_reading.ts.

deno bench example grouping with baseline

Example benchmarks with grouping and baseline comparison: ```ts Deno.bench("Date.now()", { group: "timing", baseline: true }, () => { Date.now(); }); Deno.bench("performance.now()", { group: "timing" }, () => { performance.now(); }); ``` This creates a timing group with Date.now() as baseline for comparison.

Give your agent this brain