Skip to content

Commit f183d3c

Browse files
authored
Merge pull request #3808 from asgerf/asgerf/highlevel-stats
compare-perf: Show evaluation and iteration counts in table
2 parents c08ef0e + be52ca5 commit f183d3c

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

extensions/ql-vscode/src/view/compare-performance/ComparePerformance.tsx

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ interface OptionalValue {
2626
}
2727

2828
interface PredicateInfo extends OptionalValue {
29+
evaluationCount: number;
30+
iterationCount: number;
2931
pipelines: Record<string, PipelineSummary>;
3032
}
3133

@@ -49,6 +51,8 @@ class ComparisonDataset {
4951
const index = nameToIndex.get(name);
5052
if (index == null) {
5153
return {
54+
evaluationCount: 0,
55+
iterationCount: 0,
5256
tuples: 0,
5357
absentReason: AbsentReason.NotSeen,
5458
pipelines: {},
@@ -64,6 +68,8 @@ class ComparisonDataset {
6468
}
6569
}
6670
return {
71+
evaluationCount: data.evaluationCounts[index],
72+
iterationCount: data.iterationCounts[index],
6773
tuples: tupleCost,
6874
absentReason,
6975
pipelines: data.pipelineSummaryList[index],
@@ -187,6 +193,9 @@ interface PipelineStepProps {
187193
step: string;
188194
}
189195

196+
/**
197+
* Row with details of a pipeline step, or one of the high-level stats appearing above the pipelines (evaluation/iteration counts).
198+
*/
190199
function PipelineStep(props: PipelineStepProps) {
191200
let { before, after, step } = props;
192201
if (before != null && before < 0) {
@@ -207,6 +216,46 @@ function PipelineStep(props: PipelineStepProps) {
207216
);
208217
}
209218

219+
interface HighLevelStatsProps {
220+
before: PredicateInfo;
221+
after: PredicateInfo;
222+
}
223+
224+
function HighLevelStats(props: HighLevelStatsProps) {
225+
const { before, after } = props;
226+
const hasBefore = before.absentReason !== AbsentReason.NotSeen;
227+
const hasAfter = after.absentReason !== AbsentReason.NotSeen;
228+
const showEvaluationCount =
229+
before.evaluationCount > 1 || after.evaluationCount > 1;
230+
return (
231+
<>
232+
<tr>
233+
<ChevronCell></ChevronCell>
234+
<NumberHeader>{hasBefore ? "Before" : ""}</NumberHeader>
235+
<NumberHeader>{hasAfter ? "After" : ""}</NumberHeader>
236+
<NumberHeader>{hasBefore && hasAfter ? "Delta" : ""}</NumberHeader>
237+
<NameHeader>Stats</NameHeader>
238+
</tr>
239+
{showEvaluationCount && (
240+
<PipelineStep
241+
before={before.evaluationCount || undefined}
242+
after={after.evaluationCount || undefined}
243+
step="Number of evaluations"
244+
/>
245+
)}
246+
<PipelineStep
247+
before={before.iterationCount / before.evaluationCount || undefined}
248+
after={after.iterationCount / after.evaluationCount || undefined}
249+
step={
250+
showEvaluationCount
251+
? "Number of iterations per evaluation"
252+
: "Number of iterations"
253+
}
254+
/>
255+
</>
256+
);
257+
}
258+
210259
type TRow = {
211260
name: string;
212261
before: PredicateInfo;
@@ -378,6 +427,7 @@ export function ComparePerformance(_: Record<string, never>) {
378427
</PredicateTR>
379428
{expandedPredicates.has(row.name) && (
380429
<>
430+
<HighLevelStats before={row.before} after={row.after} />
381431
{collatePipelines(
382432
row.before.pipelines,
383433
row.after.pipelines,

0 commit comments

Comments
 (0)