@@ -19,6 +19,7 @@ import { PerformanceOverviewScanner } from "../log-insights/performance-comparis
1919import type { ResultsView } from "../local-queries" ;
2020import { readJsonlFile } from "../common/jsonl-reader" ;
2121import type { SummaryEvent } from "../log-insights/log-summary" ;
22+ import type { CompletedLocalQueryInfo } from "../query-results" ;
2223
2324export class ComparePerformanceView extends AbstractWebview <
2425 ToComparePerformanceViewMessage ,
@@ -33,7 +34,35 @@ export class ComparePerformanceView extends AbstractWebview<
3334 super ( app ) ;
3435 }
3536
36- async showResults ( fromJsonLog : string , toJsonLog : string ) {
37+ async showResults (
38+ from : CompletedLocalQueryInfo ,
39+ to : CompletedLocalQueryInfo | undefined ,
40+ ) {
41+ if ( to === undefined ) {
42+ // For single-run comparisons, the performance viewer considers the 'from' side to be missing.
43+ return this . showResultsAux ( undefined , from ) ;
44+ } else {
45+ return this . showResultsAux ( from , to ) ;
46+ }
47+ }
48+
49+ private async showResultsAux (
50+ from : CompletedLocalQueryInfo | undefined ,
51+ to : CompletedLocalQueryInfo ,
52+ ) {
53+ const fromJsonLog =
54+ from === undefined ? "" : from . evaluatorLogPaths ?. jsonSummary ;
55+ const toJsonLog = to . evaluatorLogPaths ?. jsonSummary ;
56+
57+ if ( fromJsonLog === undefined || toJsonLog === undefined ) {
58+ return extLogger . showWarningMessage (
59+ `Cannot compare performance as the structured logs are missing. Did the queries complete normally?` ,
60+ ) ;
61+ }
62+ await extLogger . log (
63+ `Comparing performance of ${ from ?. getQueryName ( ) ?? "baseline" } and ${ to ?. getQueryName ( ) } ` ,
64+ ) ;
65+
3766 const panel = await this . getPanel ( ) ;
3867 panel . reveal ( undefined , false ) ;
3968
@@ -75,10 +104,14 @@ export class ComparePerformanceView extends AbstractWebview<
75104 scanLogWithProgress ( toJsonLog , fromJsonLog === "" ? "1/1" : "2/2" ) ,
76105 ] ) ;
77106
107+ const fromName =
108+ from === undefined ? "" : this . labelProvider . getLabel ( from ) ;
109+ const toName = this . labelProvider . getLabel ( to ) ;
110+
78111 await this . postMessage ( {
79112 t : "setPerformanceComparison" ,
80- from : fromPerf . getData ( ) ,
81- to : toPerf . getData ( ) ,
113+ from : { name : fromName , data : fromPerf . getData ( ) } ,
114+ to : { name : toName , data : toPerf . getData ( ) } ,
82115 comparison : fromJsonLog !== "" ,
83116 } ) ;
84117 }
0 commit comments