(setup, action, tearDown = () => {})
| 25 | |
| 26 | // Benchmark running an action n times. |
| 27 | async 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 | |
| 58 | async function getTestMapping() { |
| 59 | let smc = await new sourceMap.SourceMapConsumer(testSourceMap); |
no outgoing calls
no test coverage detected
searching dependent graphs…