diff options
| author | Kitson Kelly <me@kitsonkelly.com> | 2019-03-05 11:53:35 +1100 |
|---|---|---|
| committer | Ryan Dahl <ry@tinyclouds.org> | 2019-03-04 19:53:35 -0500 |
| commit | 17663c12326dd1053f89a3bd741807f139973dae (patch) | |
| tree | 4588e84042b0155e11d7f5442ae38a6007922585 /benching/mod.ts | |
| parent | 9f33cd28963a72d8fea0b1e99bb61ca9bec21a94 (diff) | |
Add eslint for linting (denoland/deno_std#235)
Original: https://github.com/denoland/deno_std/commit/c0390ade3de4d825423c9f0f5e1aa56ffd509942
Diffstat (limited to 'benching/mod.ts')
| -rw-r--r-- | benching/mod.ts | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/benching/mod.ts b/benching/mod.ts index 4d2f5d41e..6fa442d03 100644 --- a/benching/mod.ts +++ b/benching/mod.ts @@ -14,10 +14,10 @@ export interface BenchmarkTimer { } /** Defines a benchmark through a named function. */ -export type BenchmarkFunction = { +export interface BenchmarkFunction { (b: BenchmarkTimer): void | Promise<void>; name: string; -}; +} /** Defines a benchmark definition with configurable runs. */ export interface BenchmarkDefinition { @@ -69,7 +69,7 @@ function createBenchmarkTimer(clock: BenchmarkClock): BenchmarkTimer { }; } -const candidates: Array<BenchmarkDefinition> = []; +const candidates: BenchmarkDefinition[] = []; /** Registers a benchmark as a candidate for the runBenchmarks executor. */ export function bench( @@ -95,27 +95,27 @@ export async function runBenchmarks({ skip = /^\s*$/ }: BenchmarkRunOptions = {}): Promise<void> { // Filtering candidates by the "only" and "skip" constraint - const benchmarks: Array<BenchmarkDefinition> = candidates.filter( + const benchmarks: BenchmarkDefinition[] = candidates.filter( ({ name }) => only.test(name) && !skip.test(name) ); // Init main counters and error flag - const filtered: number = candidates.length - benchmarks.length; - let measured: number = 0; - let failed: boolean = false; + const filtered = candidates.length - benchmarks.length; + let measured = 0; + let failed = false; // Setting up a shared benchmark clock and timer const clock: BenchmarkClock = { start: NaN, stop: NaN }; - const b: BenchmarkTimer = createBenchmarkTimer(clock); + const b = createBenchmarkTimer(clock); // Iterating given benchmark definitions (await-in-loop) console.log( "running", benchmarks.length, `benchmark${benchmarks.length === 1 ? " ..." : "s ..."}` ); - for (const { name, runs, func } of benchmarks) { + for (const { name, runs = 0, func } of benchmarks) { // See https://github.com/denoland/deno/pull/1452 about groupCollapsed console.groupCollapsed(`benchmark ${name} ... `); // Trying benchmark.func - let result: string; + let result = ""; try { if (runs === 1) { // b is a benchmark timer interfacing an unset (NaN) benchmark clock @@ -126,7 +126,7 @@ export async function runBenchmarks({ } else if (runs > 1) { // Averaging runs let pendingRuns = runs; - let totalMs: number = 0; + let totalMs = 0; // Would be better 2 not run these serially while (true) { // b is a benchmark timer interfacing an unset (NaN) benchmark clock |
