-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Diego Ferreiro Val
committed
Jun 18, 2019
1 parent
edb9d25
commit f4f385b
Showing
15 changed files
with
223 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,33 @@ | ||
import { dispatch } from './state'; | ||
import { HOOKS, RUN_BENCHMARK, MODES } from './constants'; | ||
|
||
const _dispatchDescribe = (blockName: string, blockFn: Function, mode?: string) => { | ||
dispatch({ blockName, mode, name: 'start_describe_definition' }); | ||
const _dispatchDescribe = (nodeName: string, blockFn: Function, mode?: string) => { | ||
dispatch({ nodeName, mode, nodeType: 'start_describe_definition' }); | ||
blockFn(); | ||
dispatch({ name: 'finish_describe_definition' }); | ||
dispatch({ nodeName, nodeType: 'finish_describe_definition' }); | ||
}; | ||
|
||
const describe = (blockName: string, blockFn: Function) => _dispatchDescribe(blockName, blockFn); | ||
describe.only = (blockName: string, blockFn: Function) => _dispatchDescribe(blockName, blockFn, MODES.ONLY); | ||
describe.skip = (blockName: string, blockFn: Function) => _dispatchDescribe(blockName, blockFn, MODES.SKIP); | ||
|
||
const _dispatchBenchmark = (blockName: any, blockFn: Function, mode?: string) => { | ||
dispatch({ blockName, mode, name: 'start_benchmark_definition' }); | ||
const _dispatchBenchmark = (nodeName: any, blockFn: Function, mode?: string) => { | ||
dispatch({ nodeName, mode, nodeType: 'start_benchmark_definition' }); | ||
blockFn(); | ||
dispatch({ name: 'finish_benchmark_definition' }); | ||
dispatch({ nodeName, nodeType: 'finish_benchmark_definition' }); | ||
}; | ||
|
||
const benchmark = (benchmarkName: string, fn: Function) => _dispatchBenchmark(benchmarkName, fn); | ||
benchmark.only = (benchmarkName: string, fn: Function) => _dispatchBenchmark(benchmarkName, fn, MODES.ONLY); | ||
benchmark.skip = (benchmarkName: string, fn: Function) => _dispatchBenchmark(benchmarkName, fn, MODES.SKIP); | ||
|
||
const _addHook = (fn: Function, hookType: string) => dispatch({ fn, hookType, name: 'add_hook' }); | ||
const _addHook = (fn: Function, hookType: string) => dispatch({ nodeName: 'hook', fn, hookType, nodeType: 'add_hook' }); | ||
const beforeAll = (fn: Function) => _addHook(fn, HOOKS.BEFORE_ALL); | ||
const beforeEach = (fn: Function) => _addHook(fn, HOOKS.BEFORE_EACH); | ||
const before = (fn: Function) => _addHook(fn, HOOKS.BEFORE); | ||
const afterAll = (fn: Function) => _addHook(fn, HOOKS.AFTER_ALL); | ||
const afterEach = (fn: Function) => _addHook(fn, HOOKS.AFTER_EACH); | ||
const after = (fn: Function) => _addHook(fn, HOOKS.AFTER); | ||
const run = (fn: Function) => dispatch({ fn, name: RUN_BENCHMARK }); | ||
const run = (fn: Function) => dispatch({ nodeName: 'run', fn, nodeType: RUN_BENCHMARK }); | ||
|
||
export { describe, benchmark, beforeAll, beforeEach, before, afterAll, afterEach, after, run }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
export function normalizeResults(benchmarkState: any) { | ||
const { benchmarkName, executedIterations, executedTime, results } = benchmarkState; | ||
import { BenchmarkResults } from "@best/types"; | ||
|
||
export function normalizeResults(benchmarkState: BenchmarkState): BenchmarkResults { | ||
const { benchmarkName, executedIterations, executedTime: aggregate, results } = benchmarkState; | ||
|
||
return { | ||
benchmarkName, | ||
executedIterations, | ||
executedTime, | ||
aggregate, | ||
results, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.