Skip to content

Commit 2b1eb20

Browse files
committed
Show evaluation and iteration counts in table
1 parent 93da37d commit 2b1eb20

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
@@ -25,6 +25,8 @@ interface OptionalValue {
2525
}
2626

2727
interface PredicateInfo extends OptionalValue {
28+
evaluationCount: number;
29+
iterationCount: number;
2830
pipelines: Record<string, PipelineSummary>;
2931
}
3032

@@ -48,6 +50,8 @@ class ComparisonDataset {
4850
const index = nameToIndex.get(name);
4951
if (index == null) {
5052
return {
53+
evaluationCount: 0,
54+
iterationCount: 0,
5155
tuples: 0,
5256
absentReason: AbsentReason.NotSeen,
5357
pipelines: {},
@@ -63,6 +67,8 @@ class ComparisonDataset {
6367
}
6468
}
6569
return {
70+
evaluationCount: data.evaluationCounts[index],
71+
iterationCount: data.iterationCounts[index],
6672
tuples: tupleCost,
6773
absentReason,
6874
pipelines: data.pipelineSummaryList[index],
@@ -184,6 +190,9 @@ interface PipelineStepProps {
184190
step: string;
185191
}
186192

193+
/**
194+
* Row with details of a pipeline step, or one of the high-level stats appearing above the pipelines (evaluation/iteration counts).
195+
*/
187196
function PipelineStep(props: PipelineStepProps) {
188197
let { before, after, step } = props;
189198
if (before != null && before < 0) {
@@ -204,6 +213,46 @@ function PipelineStep(props: PipelineStepProps) {
204213
);
205214
}
206215

216+
interface HighLevelStatsProps {
217+
before: PredicateInfo;
218+
after: PredicateInfo;
219+
}
220+
221+
function HighLevelStats(props: HighLevelStatsProps) {
222+
const { before, after } = props;
223+
const hasBefore = before.absentReason !== AbsentReason.NotSeen;
224+
const hasAfter = after.absentReason !== AbsentReason.NotSeen;
225+
const showEvaluationCount =
226+
before.evaluationCount > 1 || after.evaluationCount > 1;
227+
return (
228+
<>
229+
<tr>
230+
<ChevronCell></ChevronCell>
231+
<NumberHeader>{hasBefore ? "Before" : ""}</NumberHeader>
232+
<NumberHeader>{hasAfter ? "After" : ""}</NumberHeader>
233+
<NumberHeader>{hasBefore && hasAfter ? "Delta" : ""}</NumberHeader>
234+
<NameHeader>Stats</NameHeader>
235+
</tr>
236+
{showEvaluationCount && (
237+
<PipelineStep
238+
before={before.evaluationCount || undefined}
239+
after={after.evaluationCount || undefined}
240+
step="Number of evaluations"
241+
/>
242+
)}
243+
<PipelineStep
244+
before={before.iterationCount / before.evaluationCount || undefined}
245+
after={after.iterationCount / after.evaluationCount || undefined}
246+
step={
247+
showEvaluationCount
248+
? "Number of iterations per evaluation"
249+
: "Number of iterations"
250+
}
251+
/>
252+
</>
253+
);
254+
}
255+
207256
function Chevron({ expanded }: { expanded: boolean }) {
208257
return <Codicon name={expanded ? "chevron-down" : "chevron-right"} />;
209258
}
@@ -350,6 +399,7 @@ export function ComparePerformance(_: Record<string, never>) {
350399
</PredicateTR>
351400
{expandedPredicates.has(row.name) && (
352401
<>
402+
<HighLevelStats before={row.before} after={row.after} />
353403
{collatePipelines(
354404
row.before.pipelines,
355405
row.after.pipelines,

0 commit comments

Comments
 (0)