Show evaluation and iteration counts in table

This commit is contained in:
Asger F
2024-11-13 11:50:42 +01:00
parent 3b0697771d
commit 96aa770e85

View File

@@ -25,6 +25,8 @@ interface OptionalValue {
} }
interface PredicateInfo extends OptionalValue { interface PredicateInfo extends OptionalValue {
evaluationCount: number;
iterationCount: number;
pipelines: Record<string, PipelineSummary>; pipelines: Record<string, PipelineSummary>;
} }
@@ -48,6 +50,8 @@ class ComparisonDataset {
const index = nameToIndex.get(name); const index = nameToIndex.get(name);
if (index == null) { if (index == null) {
return { return {
evaluationCount: 0,
iterationCount: 0,
tuples: 0, tuples: 0,
absentReason: AbsentReason.NotSeen, absentReason: AbsentReason.NotSeen,
pipelines: {}, pipelines: {},
@@ -63,6 +67,8 @@ class ComparisonDataset {
} }
} }
return { return {
evaluationCount: data.evaluationCounts[index],
iterationCount: data.iterationCounts[index],
tuples: tupleCost, tuples: tupleCost,
absentReason, absentReason,
pipelines: data.pipelineSummaryList[index], pipelines: data.pipelineSummaryList[index],
@@ -184,6 +190,9 @@ interface PipelineStepProps {
step: string; step: string;
} }
/**
* Row with details of a pipeline step, or one of the high-level stats appearing above the pipelines (evaluation/iteration counts).
*/
function PipelineStep(props: PipelineStepProps) { function PipelineStep(props: PipelineStepProps) {
let { before, after, step } = props; let { before, after, step } = props;
if (before != null && before < 0) { if (before != null && before < 0) {
@@ -204,6 +213,46 @@ function PipelineStep(props: PipelineStepProps) {
); );
} }
interface HighLevelStatsProps {
before: PredicateInfo;
after: PredicateInfo;
}
function HighLevelStats(props: HighLevelStatsProps) {
const { before, after } = props;
const hasBefore = before.absentReason !== AbsentReason.NotSeen;
const hasAfter = after.absentReason !== AbsentReason.NotSeen;
const showEvaluationCount =
before.evaluationCount > 1 || after.evaluationCount > 1;
return (
<>
<tr>
<ChevronCell></ChevronCell>
<NumberHeader>{hasBefore ? "Before" : ""}</NumberHeader>
<NumberHeader>{hasAfter ? "After" : ""}</NumberHeader>
<NumberHeader>{hasBefore && hasAfter ? "Delta" : ""}</NumberHeader>
<NameHeader>Stats</NameHeader>
</tr>
{showEvaluationCount && (
<PipelineStep
before={before.evaluationCount || undefined}
after={after.evaluationCount || undefined}
step="Number of evaluations"
/>
)}
<PipelineStep
before={before.iterationCount / before.evaluationCount || undefined}
after={after.iterationCount / after.evaluationCount || undefined}
step={
showEvaluationCount
? "Number of iterations per evaluation"
: "Number of iterations"
}
/>
</>
);
}
function Chevron({ expanded }: { expanded: boolean }) { function Chevron({ expanded }: { expanded: boolean }) {
return <Codicon name={expanded ? "chevron-down" : "chevron-right"} />; return <Codicon name={expanded ? "chevron-down" : "chevron-right"} />;
} }
@@ -350,6 +399,7 @@ export function ComparePerformance(_: Record<string, never>) {
</PredicateTR> </PredicateTR>
{expandedPredicates.has(row.name) && ( {expandedPredicates.has(row.name) && (
<> <>
<HighLevelStats before={row.before} after={row.after} />
{collatePipelines( {collatePipelines(
row.before.pipelines, row.before.pipelines,
row.after.pipelines, row.after.pipelines,