Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Aug 1, 2019
1 parent caa3886 commit c8a2dbc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/benchmark/loop.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ const benchmarkIteration = async function({
}) {
const repeat = getRepeat({ main, state, minTime, loopBias })

const time = await measure(
const time = await measure({
main,
before,
after,
nowBias,
loopBias,
repeat,
isAsync,
)
})

const stateA = updateState(state, time, repeat)
return stateA
Expand Down
9 changes: 8 additions & 1 deletion src/benchmark/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ export const benchmark = async function({ main, before, after, duration }) {
// the bias calculation.
const initialMeasure = function(isAsync, before) {
const beforeFunc = before === undefined ? undefined : noop
measure(noop, beforeFunc, undefined, 0, 0, 1, isAsync)
measure({
main: noop,
before: beforeFunc,
nowBias: 0,
loopBias: 0,
repeat: 1,
isAsync,
})
}

// This needs to be a different function from the `noop` used during bias
Expand Down
7 changes: 4 additions & 3 deletions src/benchmark/measure.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ import { now } from '../now.js'

import { getDuration } from './duration.js'

// Main measuring code. If `repeat` is specified, we perform an arithmetic mean.
export const measure = async function(
// Main measuring code.
// If `repeat` is specified, we loop and perform an arithmetic mean.
export const measure = async function({
main,
before,
after,
nowBias,
loopBias,
repeat,
isAsync,
) {
}) {
// When calculating `nowBias`
if (main === undefined) {
return -now() + now()
Expand Down
1 change: 1 addition & 0 deletions src/benchmark/normalize.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { sortNumbers } from '../utils.js'

// Transform raw results into a result object that can be used by parent
export const normalizeResult = function(times, count) {
sortNumbers(times)

Expand Down

0 comments on commit c8a2dbc

Please sign in to comment.