diff --git a/src/report/reporters/boxplot/main.js b/src/report/reporters/boxplot/main.js index 2769ba573..c5660edc2 100644 --- a/src/report/reporters/boxplot/main.js +++ b/src/report/reporters/boxplot/main.js @@ -8,11 +8,11 @@ import { NAME_SEPARATOR_COLORED } from '../../utils/separator.js' // Reporter showing boxplot of measures (min, p25, median, p75, max) const reportTerminal = function ({ combinations, screenWidth }) { - const showStats = true - const width = getContentWidth(combinations, showStats, screenWidth) + const mini = false + const width = getContentWidth(combinations, mini, screenWidth) const { minAll, maxAll } = getMinMaxAll(combinations) return combinations.map((combination) => - serializeBoxPlot({ combination, minAll, maxAll, width, showStats }), + serializeBoxPlot({ combination, minAll, maxAll, width, mini }), ) } @@ -20,12 +20,12 @@ const getMinMaxAll = function (combinations) { combinations.filter(isMeasuredCombination) } -const getContentWidth = function (combinations, showStats, screenWidth) { +const getContentWidth = function (combinations, mini, screenWidth) { return Math.max( screenWidth - getTitleBlockWidth(combinations) - - getMinBlockWidth(combinations, showStats) - - getMaxBlockWidth(combinations, showStats), + getMinBlockWidth(combinations, mini) - + getMaxBlockWidth(combinations, mini), 1, ) } @@ -38,17 +38,17 @@ const serializeBoxPlot = function ({ minAll, maxAll, width, - showStats, + mini, }) { - const titleBlock = getTitleBlock(combination, showStats) + const titleBlock = getTitleBlock(combination, mini) if (!isMeasuredCombination(combination)) { return titleBlock } - const minBlock = getMinBlock(quantiles, showStats) - const content = getContent({ quantiles, minAll, maxAll, showStats, width }) - const maxBlock = getMaxBlock(quantiles, showStats) + const minBlock = getMinBlock(quantiles, mini) + const content = getContent({ quantiles, minAll, maxAll, mini, width }) + const maxBlock = getMaxBlock(quantiles, mini) return concatBlocks([titleBlock, minBlock, content, maxBlock]) } @@ -58,9 +58,9 @@ const isMeasuredCombination = function ({ stats: { quantiles } }) { } // Retrieve sidebar with the combination name -const getTitleBlock = function (combination, showStats) { +const getTitleBlock = function (combination, mini) { const titleBlockContents = getTitleBlockContents(combination) - const bottomNewlines = getBottomNewlines(showStats) + const bottomNewlines = getBottomNewlines(mini) return `${titleBlockContents}\n${bottomNewlines}` } @@ -72,8 +72,8 @@ const getTitleBlockContents = function (combination) { return `${getCombinationNameColor(combination)}${NAME_SEPARATOR_COLORED}` } -const getBottomNewlines = function (showStats) { - const bottomNewlinesHeight = showStats ? LABELS_HEIGHT : 0 +const getBottomNewlines = function (mini) { + const bottomNewlinesHeight = mini ? 0 : LABELS_HEIGHT return '\n'.repeat(bottomNewlinesHeight) } @@ -81,19 +81,19 @@ const LABELS_HEIGHT = 1 // Retrieve the blocks that show the lowest|highest value of the histogram, on // the left|right of it -const getBlock = function (getStat, quantiles, showStats) { - return showStats ? getStat(quantiles) : '' +const getBlock = function (getStat, quantiles, mini) { + return mini ? '' : getStat(quantiles) } // Retrieve the width of those blocks -const getBlockWidth = function (getStat, combinations, showStats) { - return showStats - ? Math.max( +const getBlockWidth = function (getStat, combinations, mini) { + return mini + ? 0 + : Math.max( ...combinations.map((combination) => getCombinationWidth(combination, getStat), ), ) - : 0 } const getCombinationWidth = function ({ stats: { quantiles } }, getStat) { @@ -118,11 +118,11 @@ const getMinBlockWidth = getBlockWidth.bind(undefined, getMinStat) const getMaxBlock = getBlock.bind(undefined, getMaxStat) const getMaxBlockWidth = getBlockWidth.bind(undefined, getMaxStat) -const getContent = function ({ quantiles, minAll, maxAll, width, showStats }) { +const getContent = function ({ quantiles, minAll, maxAll, width, mini }) { const positions = getPositions({ quantiles, minAll, maxAll, width }) const box = getBox(positions, width) - if (!showStats) { + if (mini) { return box } diff --git a/src/report/reporters/debug/main.js b/src/report/reporters/debug/main.js index af9ff0a90..fd384ee01 100644 --- a/src/report/reporters/debug/main.js +++ b/src/report/reporters/debug/main.js @@ -8,7 +8,7 @@ const reportTerminal = function ({ combinations, screenWidth, history }) { const statsTables = getStatsTables(combinations, screenWidth) const timeSeries = getTimeSeries(history, combinations, screenWidth) const histograms = serializeHistograms(combinations, { - showStats: false, + mini: true, screenWidth, }) return [statsTables, timeSeries, histograms].join('\n\n') diff --git a/src/report/reporters/histogram.js b/src/report/reporters/histogram.js index 20329f64e..f78215aee 100644 --- a/src/report/reporters/histogram.js +++ b/src/report/reporters/histogram.js @@ -2,7 +2,7 @@ import { serializeHistograms } from '../utils/histogram/main.js' // Reporter showing distribution of measures with a histogram const reportTerminal = function ({ combinations, screenWidth }) { - return serializeHistograms(combinations, { showStats: true, screenWidth }) + return serializeHistograms(combinations, { mini: false, screenWidth }) } export const histogram = { reportTerminal } diff --git a/src/report/utils/histogram/content.js b/src/report/utils/histogram/content.js index e515499e6..f48dfb004 100644 --- a/src/report/utils/histogram/content.js +++ b/src/report/utils/histogram/content.js @@ -8,7 +8,7 @@ export const getContent = function ({ stats: { histogram }, height, width, - showStats, + mini, }) { const { positions, meanIndex, meanMaxWidth } = getMeanPositions(stats, width) const rows = getHistogramRows({ @@ -19,7 +19,7 @@ export const getContent = function ({ meanMaxWidth, }) - if (!showStats) { + if (mini) { return rows } diff --git a/src/report/utils/histogram/main.js b/src/report/utils/histogram/main.js index 81cc2248c..62950c9e2 100644 --- a/src/report/utils/histogram/main.js +++ b/src/report/utils/histogram/main.js @@ -13,25 +13,25 @@ import { getTitleBlock, getTitleBlockWidth } from './title.js' // Serialize combinations' histograms for reporting export const serializeHistograms = function ( combinations, - { showStats, screenWidth }, + { mini, screenWidth }, ) { const height = DEFAULT_HEIGHT - const width = getContentWidth(combinations, showStats, screenWidth) + const width = getContentWidth(combinations, mini, screenWidth) return combinations .map((combination) => - serializeHistogram({ combination, width, height, showStats }), + serializeHistogram({ combination, width, height, mini }), ) .join('\n') } const DEFAULT_HEIGHT = 2 * EXTRA_HEIGHT -const getContentWidth = function (combinations, showStats, screenWidth) { +const getContentWidth = function (combinations, mini, screenWidth) { return Math.max( screenWidth - getTitleBlockWidth(combinations) - - getMinBlockWidth(combinations, showStats) - - getMaxBlockWidth(combinations, showStats), + getMinBlockWidth(combinations, mini) - + getMaxBlockWidth(combinations, mini), 1, ) } @@ -41,17 +41,17 @@ const serializeHistogram = function ({ combination: { stats }, width, height, - showStats, + mini, }) { - const titleBlock = getTitleBlock(combination, height, showStats) + const titleBlock = getTitleBlock(combination, height, mini) if (hasLowLoops(stats)) { return titleBlock } - const minBlock = getMinBlock({ stats, height, showStats }) - const content = getContent({ stats, height, width, showStats }) - const maxBlock = getMaxBlock({ stats, height, showStats }) + const minBlock = getMinBlock({ stats, height, mini }) + const content = getContent({ stats, height, width, mini }) + const maxBlock = getMaxBlock({ stats, height, mini }) return concatBlocks([titleBlock, minBlock, content, maxBlock]) } diff --git a/src/report/utils/histogram/min_max.js b/src/report/utils/histogram/min_max.js index ea4bcaebd..e17f98e3e 100644 --- a/src/report/utils/histogram/min_max.js +++ b/src/report/utils/histogram/min_max.js @@ -6,8 +6,8 @@ import { TICK_LEFT, TICK_RIGHT } from './characters.js' // Retrieve the blocks that show the lowest|highest value of the histogram, on // the left|right of it -const getBlock = function (getStat, { stats, height, showStats }) { - if (!showStats) { +const getBlock = function (getStat, { stats, height, mini }) { + if (mini) { return '' } @@ -17,8 +17,8 @@ const getBlock = function (getStat, { stats, height, showStats }) { } // Retrieve the width of those blocks -const getBlockWidth = function (getStat, combinations, showStats) { - if (!showStats) { +const getBlockWidth = function (getStat, combinations, mini) { + if (mini) { return 0 } diff --git a/src/report/utils/histogram/title.js b/src/report/utils/histogram/title.js index 031b02bcc..69f1c96c0 100644 --- a/src/report/utils/histogram/title.js +++ b/src/report/utils/histogram/title.js @@ -6,9 +6,9 @@ import { NAME_SEPARATOR_COLORED } from '../separator.js' import { ABSCISSA_BOTTOM_HEIGHT, ABSCISSA_LABELS_HEIGHT } from './abscissa.js' // Retrieve sidebar with the combination name -export const getTitleBlock = function (combination, height, showStats) { - const topNewlines = getTopNewlines(height, showStats) - const bottomNewlines = getBottomNewlines(showStats) +export const getTitleBlock = function (combination, height, mini) { + const topNewlines = getTopNewlines(height, mini) + const bottomNewlines = getBottomNewlines(mini) const titleBlockContents = getTitleBlockContents(combination) return `${topNewlines}${titleBlockContents}\n${bottomNewlines}` } @@ -21,12 +21,12 @@ const getTitleBlockContents = function (combination) { return `${getCombinationNameColor(combination)}${NAME_SEPARATOR_COLORED}` } -const getTopNewlines = function (height, showStats) { - const topNewlinesHeight = height - (showStats ? 0 : ABSCISSA_BOTTOM_HEIGHT) +const getTopNewlines = function (height, mini) { + const topNewlinesHeight = height - (mini ? ABSCISSA_BOTTOM_HEIGHT : 0) return '\n'.repeat(topNewlinesHeight) } -const getBottomNewlines = function (showStats) { - const bottomNewlinesHeight = showStats ? ABSCISSA_LABELS_HEIGHT : 0 +const getBottomNewlines = function (mini) { + const bottomNewlinesHeight = mini ? 0 : ABSCISSA_LABELS_HEIGHT return '\n'.repeat(bottomNewlinesHeight) }