diff --git a/src/backend/compare/compare.ts b/src/backend/compare/compare.ts index 3103f48e..db4f23fa 100644 --- a/src/backend/compare/compare.ts +++ b/src/backend/compare/compare.ts @@ -98,10 +98,10 @@ export async function getMeasurements( name: 'fetchMeasurementsByProjectIdRunIdCommitId', text: `SELECT trialId, source.commitId as commitId, - invocation, iteration, warmup, + invocation, warmup, criterion.name as criterion, criterion.unit as unit, - value + values FROM Measurement JOIN Trial ON trialId = Trial.id @@ -113,7 +113,7 @@ export async function getMeasurements( WHERE Project.slug = $1 AND runId = $2 AND (source.commitId = $3 OR source.commitId = $4) - ORDER BY trialId, criterion, invocation, iteration;`, + ORDER BY trialId, criterion, invocation;`, values: [projectSlug, runId, baseCommitId, changeCommitId] }; const result = await db.query(q); @@ -154,7 +154,7 @@ export async function getMeasurements( critObject.values[r.invocation - 1] = []; } - critObject.values[r.invocation - 1][r.iteration - 1] = r.value; + critObject.values[r.invocation - 1] = r.values; } } diff --git a/src/frontend/plots.ts b/src/frontend/plots.ts index a082f0e0..cb54c7dc 100644 --- a/src/frontend/plots.ts +++ b/src/frontend/plots.ts @@ -1,4 +1,10 @@ -import type { AllResults, PlotData, TimelineResponse } from '../shared/api.js'; +import type { + AllResults, + CriterionWithoutData, + PlotData, + TimelineResponse, + ValuesPossiblyMissing +} from '../shared/api.js'; import type { Source } from '../backend/db/types.js'; import { filterCommitMessage } from './render.js'; import uPlot from '/static/uPlot.esm.min.js'; @@ -411,7 +417,7 @@ export function renderComparisonTimelinePlot( /** * Replace `0` with `null` to hide the point in the plot. */ -function replaceZeroByNull(data: number[]): number[] { +function replaceZeroByNull(data: ValuesPossiblyMissing): ValuesPossiblyMissing { for (let i = 0; i < data.length; i += 1) { if (data[i] === 0) { (data)[i] = null; @@ -423,7 +429,7 @@ function replaceZeroByNull(data: number[]): number[] { function addSeries( critData: WarmupDataPerCriterion, - data: number[][], + data: (ValuesPossiblyMissing | CriterionWithoutData)[], series: any[], commitId: string, colors: readonly string[], @@ -435,7 +441,14 @@ function addSeries( 'Do not yet know how to handle multiple.' ); } - data.push(replaceZeroByNull(critData.values[0])); + + const values = critData.values[0]; + + if (values === null) { + return 0; + } + + data.push(replaceZeroByNull(values)); const style = styleMap[critData.criterion]; @@ -454,7 +467,7 @@ function addSeries( cfg.points.fill = colors[style.colorIdx]; } - return critData.values[0].length; + return values.length; } function collectUnitsAndCriteria(data: WarmupDataForTrial[]): { diff --git a/src/shared/view-types.ts b/src/shared/view-types.ts index 40ee8c4d..2f35729b 100644 --- a/src/shared/view-types.ts +++ b/src/shared/view-types.ts @@ -1,4 +1,9 @@ -import type { BenchmarkId, ProfileElement } from './api.js'; +import type { + BenchmarkId, + CriterionWithoutData, + ProfileElement, + ValuesPossiblyMissing +} from './api.js'; import type { CriterionData, Environment, @@ -247,7 +252,7 @@ export type CompareView = CompareViewWithoutData | CompareViewWithData; export interface WarmupDataPerCriterion { criterion: string; unit: string; - values: number[][]; + values: (ValuesPossiblyMissing | CriterionWithoutData)[]; } export interface WarmupDataForTrial {