From 44ce640fba1d54dbd5ff3dd4986d09a7ec7593a9 Mon Sep 17 00:00:00 2001 From: Paul Aiden Williams Date: Fri, 24 Jul 2026 13:30:57 -0400 Subject: [PATCH] Update 2 cross-run-trace-analysis.tsx Adds option to suppress leading / ending zeroes. Purely for better data visualization, not a statistical method. --- web/components/cross-run-trace-analysis.tsx | 96 ++++++++++++++++++++- 1 file changed, 93 insertions(+), 3 deletions(-) diff --git a/web/components/cross-run-trace-analysis.tsx b/web/components/cross-run-trace-analysis.tsx index 0ecedf9..4eb80c7 100644 --- a/web/components/cross-run-trace-analysis.tsx +++ b/web/components/cross-run-trace-analysis.tsx @@ -245,6 +245,50 @@ function toggleInList(items: T[], item: T): T[] { : [...items, item]; } +#PAUL +function suppressLeadingTrailingZeroes( + values: Array, + minConsecutiveZeroes = 2, +): Array { + const result = [...values]; + + let leadingZeroCount = 0; + for (const value of result) { + if (value === 0) { + leadingZeroCount += 1; + } else { + break; + } + } + + let trailingZeroCount = 0; + for (let index = result.length - 1; index >= 0; index -= 1) { + if (result[index] === 0) { + trailingZeroCount += 1; + } else { + break; + } + } + + if (leadingZeroCount >= minConsecutiveZeroes) { + for (let index = 0; index < leadingZeroCount; index += 1) { + result[index] = null; + } + } + + if (trailingZeroCount >= minConsecutiveZeroes) { + for ( + let index = result.length - trailingZeroCount; + index < result.length; + index += 1 + ) { + result[index] = null; + } + } + + return result; +} + export function CrossRunTraceAnalysis() { const [runs, setRuns] = useState([]); const [catalogLoading, setCatalogLoading] = useState(true); @@ -264,6 +308,7 @@ export function CrossRunTraceAnalysis() { const [selectedParameterKeys, setSelectedParameterKeys] = useState(null); const [selectedRunIds, setSelectedRunIds] = useState(null); const [axisMode, setAxisMode] = useState("absolute"); + const [suppressEdgeZeroes, setSuppressEdgeZeroes] = useState(false); #PAUL const [traceResult, setTraceResult] = useState({ requestKey: "", traces: [], @@ -1003,6 +1048,44 @@ export function CrossRunTraceAnalysis() { {positionedTraces.length.toLocaleString()} runs ยท {selectedParameters.length.toLocaleString()} parameters

+ +
+ + +
+ Time axis +
+ {AXIS_MODES.map((mode) => { + const Icon = mode.icon; + return ( + + ); + })} +
+
+
+
Time axis
@@ -1067,6 +1150,15 @@ export function CrossRunTraceAnalysis() { ); const plotData = panelPositionedTraces.map((positioned) => { const { trace, run, offsetSeconds, color } = positioned; + + const rawYValues = trace.samples.map((sample) => + finiteValue(sample.values[parameter.key]), + ); + + const yValues = suppressEdgeZeroes + ? suppressLeadingTrailingZeroes(rawYValues, 2) + : rawYValues; + return { x: trace.samples.map((sample) => { if (axisMode === "absolute") return sample.timestamp; @@ -1075,9 +1167,7 @@ export function CrossRunTraceAnalysis() { } return sample.relative_seconds; }), - y: trace.samples.map((sample) => - finiteValue(sample.values[parameter.key]), - ), + y: yValues, text: trace.samples.map((sample) => { const compressedHours = (offsetSeconds + sample.relative_seconds) / 3_600;