MCPcopy Index your code
hub / github.com/mozilla/source-map / benchmark

Function benchmark

bench/bench.js:27–56  ·  view source on GitHub ↗
(setup, action, tearDown = () => {})

Source from the content-addressed store, hash-verified

25
26// Benchmark running an action n times.
27async function benchmark(setup, action, tearDown = () => {}) {
28 __benchmarkResults = [];
29
30 console.time("setup");
31 await setup();
32 console.timeEnd("setup");
33
34 // Warm up the JIT.
35 console.time("warmup");
36 for (let i = 0; i < WARM_UP_ITERATIONS; i++) {
37 await action();
38 await yieldForTick();
39 }
40 console.timeEnd("warmup");
41
42 const stats = new Stats("ms");
43
44 for (let i = 0; i < BENCH_ITERATIONS; i++) {
45 console.time("iteration");
46 const thisIterationStart = now();
47 await action();
48 stats.take(now() - thisIterationStart);
49 console.timeEnd("iteration");
50
51 await yieldForTick();
52 }
53
54 await tearDown();
55 return stats;
56}
57
58async function getTestMapping() {
59 let smc = await new sourceMap.SourceMapConsumer(testSourceMap);

Callers 1

bench.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…