Skip to content

Commit

Permalink
Add config selectors for precision and outliers
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Jan 16, 2022
1 parent beabf7a commit e3108c2
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 26 deletions.
4 changes: 1 addition & 3 deletions src/combination/tasks/find.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ export const findTasks = async function ({
const [{ taskIds: ids }] = await measureCombinations(
[{ dimensions: { runner }, taskPath, inputsList: [] }],
{
precision: 0,
cwd,
config: { precision: 0, cwd, outliers: true },
previewState: { quiet: true },
outliers: true,
stage: 'init',
noDimensions,
},
Expand Down
8 changes: 4 additions & 4 deletions src/config/select/apply.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import { SELECTABLE_PROPS } from './normalize.js'
export const applyConfigSelectors = function (combination, config) {
return mapObj(config, (name, configValue) => [
name,
applyConfigPropSelectors(combination, configValue),
applyConfigPropSelectors(combination, configValue, name),
])
}

const applyConfigPropSelectors = function (combination, configValue) {
if (!isParsedConfigSelector(configValue)) {
const applyConfigPropSelectors = function (combination, configValue, name) {
if (!isParsedConfigSelector(configValue, name)) {
return configValue
}

Expand All @@ -28,7 +28,7 @@ const applyConfigPropSelectors = function (combination, configValue) {
}

// Make the logic a noop if the configuration property does not use selectors
const isParsedConfigSelector = function (name, configValue) {
const isParsedConfigSelector = function (configValue, name) {
return (
SELECTABLE_PROPS.has(name) &&
Array.isArray(configValue) &&
Expand Down
4 changes: 1 addition & 3 deletions src/dev/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ const combinationDev = async function (combination, noDimensions, { cwd }) {
printCombinationName(combination, noDimensions)

await measureCombinations([combination], {
precision: 0,
cwd,
config: { precision: 0, cwd, outliers: true },
previewState: { quiet: true },
outliers: true,
stage: 'dev',
noDimensions,
})
Expand Down
5 changes: 1 addition & 4 deletions src/run/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ const previewAndMeasure = async function ({
noDimensions,
previewState,
config,
config: { cwd, precision, outliers },
}) {
const previewStateA = await startPreview({
newResult,
Expand All @@ -68,10 +67,8 @@ const previewAndMeasure = async function ({

try {
const combinations = await measureCombinations(newResult.combinations, {
precision,
cwd,
config,
previewState: previewStateA,
outliers,
stage: 'main',
noDimensions,
})
Expand Down
3 changes: 1 addition & 2 deletions src/run/measure/loop.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ import { isRemainingCombination } from './remaining.js'
// In that case, the task complexity should be increased, for example by using
// bigger `inputs`.
export const performMeasureLoop = async function ({
precision,
config: { precision, outliers },
previewState,
stopState,
stage,
outliers,
server,
logsFd,
minLoopDuration,
Expand Down
14 changes: 5 additions & 9 deletions src/run/measure/single.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getCombinationPrefix } from '../../combination/ids/name.js'
import { applyConfigSelectors } from '../../config/select/apply.js'
import { startLogs, stopLogs, hasLogs } from '../logs/create.js'
import { addErrorTaskLogs } from '../logs/error.js'
import { startLogsStream, stopLogsStream } from '../logs/stream.js'
Expand All @@ -16,8 +17,9 @@ import { throwIfStopped } from '../stop/error.js'
import { runEvents } from './events.js'

// Measure a single combination
export const measureCombination = async function ({ index, ...args }) {
export const measureCombination = async function ({ index, config, ...args }) {
const { previewState, combination, noDimensions } = args
const configA = applyConfigSelectors(combination, config)

try {
await startCombinationPreview({
Expand All @@ -26,7 +28,7 @@ export const measureCombination = async function ({ index, ...args }) {
index,
noDimensions,
})
const { stats, taskIds } = await logAndMeasure(args)
const { stats, taskIds } = await logAndMeasure({ ...args, config: configA })
await endCombinationPreview(previewState)
return { ...combination, stats, taskIds }
} finally {
Expand Down Expand Up @@ -62,15 +64,9 @@ const logStreamAndMeasure = async function (args) {
}

// Spawn combination processes, then measure them
const spawnAndMeasure = async function ({
cwd,
serverUrl,
logsStream,
...args
}) {
const spawnAndMeasure = async function ({ serverUrl, logsStream, ...args }) {
const { childProcess, onTaskExit } = await spawnRunnerProcess({
...args,
cwd,
serverUrl,
logsStream,
})
Expand Down
2 changes: 1 addition & 1 deletion src/run/process/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const spawnRunnerProcess = async function ({
},
},
},
cwd,
config: { cwd },
server,
serverUrl,
logsStream,
Expand Down

0 comments on commit e3108c2

Please sign in to comment.