Skip to content

Commit

Permalink
Put all the sorting related bits close to each other
Browse files Browse the repository at this point in the history
  • Loading branch information
smarr committed May 5, 2023
1 parent 9a663cf commit d7feffd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -499,14 +499,10 @@ export async function calculateAllStatisticsAndRenderPlots(
change: string,
reportId: string
): Promise<StatsSummary> {
const cmp = base.localeCompare(change);
if (cmp === 0) {
throw new Error('base and change are the same');
}
const baseCommitIdIsFirst = cmp < 0;

const baseOffset = baseCommitIdIsFirst ? 0 : 1;
const changeOffset = baseCommitIdIsFirst ? 1 : 0;
const { baseOffset, changeOffset } = getCommitOffsetsInSortedMeasurements(

Check failure on line 502 in src/dashboard.ts

View workflow job for this annotation

GitHub Actions / build-and-test

Cannot find name 'getCommitOffsetsInSortedMeasurements'.
base,
change
);

const criteria = new Map<string, ComparisonStatistics[]>();

Expand Down
16 changes: 16 additions & 0 deletions src/stats-data-prep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,22 @@ export function compareToSortForSinglePassChangeStatsWithoutCommitId(
return a.criterion.name.localeCompare(b.criterion.name);
}

export function getCommitOffsetsInSortedMeasurements(
baseCommitId: string,
changeCommitId: string
): { baseOffset: number; changeOffset: number } {
const cmp = baseCommitId.localeCompare(changeCommitId);
if (cmp === 0) {
throw new Error('base and change are the same');
}
const baseCommitIdIsFirst = cmp < 0;

return {
baseOffset: baseCommitIdIsFirst ? 0 : 1,
changeOffset: baseCommitIdIsFirst ? 1 : 0
};
}

export interface ResultsByBenchmark {
benchmarks: Map<string, ProcessedResult>;
criteria: Record<string, CriterionData>;
Expand Down

0 comments on commit d7feffd

Please sign in to comment.