@@ -28,6 +28,7 @@ interface OptionalValue {
2828interface PredicateInfo extends OptionalValue {
2929 evaluationCount : number ;
3030 iterationCount : number ;
31+ timeCost : number ;
3132 pipelines : Record < string , PipelineSummary > ;
3233}
3334
@@ -54,6 +55,7 @@ class ComparisonDataset {
5455 evaluationCount : 0 ,
5556 iterationCount : 0 ,
5657 tuples : 0 ,
58+ timeCost : 0 ,
5759 absentReason : AbsentReason . NotSeen ,
5860 pipelines : { } ,
5961 } ;
@@ -70,14 +72,15 @@ class ComparisonDataset {
7072 return {
7173 evaluationCount : data . evaluationCounts [ index ] ,
7274 iterationCount : data . iterationCounts [ index ] ,
75+ timeCost : data . timeCosts [ index ] ,
7376 tuples : tupleCost ,
7477 absentReason,
7578 pipelines : data . pipelineSummaryList [ index ] ,
7679 } ;
7780 }
7881}
7982
80- function renderAbsoluteValue ( x : OptionalValue ) {
83+ function renderAbsoluteValue ( x : PredicateInfo , metric : Metric ) {
8184 switch ( x . absentReason ) {
8285 case AbsentReason . NotSeen :
8386 return < AbsentNumberCell > n/a</ AbsentNumberCell > ;
@@ -86,7 +89,12 @@ function renderAbsoluteValue(x: OptionalValue) {
8689 case AbsentReason . Sentinel :
8790 return < AbsentNumberCell > sentinel empty</ AbsentNumberCell > ;
8891 default :
89- return < NumberCell > { formatDecimal ( x . tuples ) } </ NumberCell > ;
92+ return (
93+ < NumberCell >
94+ { formatDecimal ( metric . get ( x ) ) }
95+ { renderUnit ( metric . unit ) }
96+ </ NumberCell >
97+ ) ;
9098 }
9199}
92100
@@ -97,7 +105,8 @@ const DeltaPositive = styled(Codicon)`
97105const DeltaNegative = styled ( Codicon ) `
98106 color: var(--vscode-problemsInfoIcon-foreground);
99107` ;
100- function renderDelta ( x : number ) {
108+
109+ function renderDelta ( x : number , unit ?: string ) {
101110 const sign = x > 0 ? "+" : "" ;
102111 const symbol =
103112 x > 0 ? (
@@ -109,11 +118,16 @@ function renderDelta(x: number) {
109118 < NumberCell >
110119 { sign }
111120 { formatDecimal ( x ) }
121+ { renderUnit ( unit ) }
112122 { symbol }
113123 </ NumberCell >
114124 ) ;
115125}
116126
127+ function renderUnit ( unit : string | undefined ) {
128+ return unit == null ? "" : ` ${ unit } ` ;
129+ }
130+
117131function orderBy < T > ( fn : ( x : T ) => number | string ) {
118132 return ( x : T , y : T ) => {
119133 const fx = fn ( x ) ;
@@ -199,7 +213,7 @@ const PipelineStepTR = styled.tr`
199213 }
200214` ;
201215
202- const SortOrderDropdown = styled . select `` ;
216+ const Dropdown = styled . select `` ;
203217
204218interface PipelineStepProps {
205219 before : number | undefined ;
@@ -288,6 +302,37 @@ function getSortOrder(sortOrder: "delta" | "absDelta") {
288302 return orderBy ( ( row : TRow ) => row . diff ) ;
289303}
290304
305+ interface Metric {
306+ title : string ;
307+ get ( info : PredicateInfo ) : number ;
308+ unit ?: string ;
309+ }
310+
311+ const metrics : Record < string , Metric > = {
312+ tuples : {
313+ title : "Tuples in pipeline" ,
314+ get : ( info ) => info . tuples ,
315+ } ,
316+ time : {
317+ title : "Time spent (milliseconds)" ,
318+ get : ( info ) => info . timeCost ,
319+ unit : "ms" ,
320+ } ,
321+ evaluations : {
322+ title : "Evaluations" ,
323+ get : ( info ) => info . evaluationCount ,
324+ } ,
325+ iterations : {
326+ title : "Iterations (per evaluation)" ,
327+ get : ( info ) =>
328+ info . absentReason ? 0 : info . iterationCount / info . evaluationCount ,
329+ } ,
330+ iterationsTotal : {
331+ title : "Iterations (total)" ,
332+ get : ( info ) => info . iterationCount ,
333+ } ,
334+ } ;
335+
291336function Chevron ( { expanded } : { expanded : boolean } ) {
292337 return < Codicon name = { expanded ? "chevron-down" : "chevron-right" } /> ;
293338}
@@ -333,6 +378,8 @@ export function ComparePerformance(_: Record<string, never>) {
333378
334379 const [ sortOrder , setSortOrder ] = useState < "delta" | "absDelta" > ( "delta" ) ;
335380
381+ const [ metric , setMetric ] = useState < Metric > ( metrics . tuples ) ;
382+
336383 if ( ! datasets ) {
337384 return < div > Loading performance comparison...</ div > ;
338385 }
@@ -350,7 +397,9 @@ export function ComparePerformance(_: Record<string, never>) {
350397 . map ( ( name ) => {
351398 const before = from . getTupleCountInfo ( name ) ;
352399 const after = to . getTupleCountInfo ( name ) ;
353- if ( before . tuples === after . tuples ) {
400+ const beforeValue = metric . get ( before ) ;
401+ const afterValue = metric . get ( after ) ;
402+ if ( beforeValue === afterValue ) {
354403 return undefined ! ;
355404 }
356405 if (
@@ -362,7 +411,7 @@ export function ComparePerformance(_: Record<string, never>) {
362411 return undefined ! ;
363412 }
364413 }
365- const diff = after . tuples - before . tuples ;
414+ const diff = afterValue - beforeValue ;
366415 return { name, before, after, diff } ;
367416 } )
368417 . filter ( ( x ) => ! ! x )
@@ -373,8 +422,8 @@ export function ComparePerformance(_: Record<string, never>) {
373422 let totalDiff = 0 ;
374423
375424 for ( const row of rows ) {
376- totalBefore += row . before . tuples ;
377- totalAfter += row . after . tuples ;
425+ totalBefore += metric . get ( row . before ) ;
426+ totalAfter += metric . get ( row . after ) ;
378427 totalDiff += row . diff ;
379428 }
380429
@@ -402,15 +451,28 @@ export function ComparePerformance(_: Record<string, never>) {
402451 </ label >
403452 </ WarningBox >
404453 ) }
405- < SortOrderDropdown
454+ Compare{ " " }
455+ < Dropdown
456+ onChange = { ( e : ChangeEvent < HTMLSelectElement > ) =>
457+ setMetric ( metrics [ e . target . value ] )
458+ }
459+ >
460+ { Object . entries ( metrics ) . map ( ( [ key , value ] ) => (
461+ < option key = { key } value = { key } >
462+ { value . title }
463+ </ option >
464+ ) ) }
465+ </ Dropdown > { " " }
466+ sorted by{ " " }
467+ < Dropdown
406468 onChange = { ( e : ChangeEvent < HTMLSelectElement > ) =>
407469 setSortOrder ( e . target . value as "delta" | "absDelta" )
408470 }
409471 value = { sortOrder }
410472 >
411473 < option value = "delta" > Delta</ option >
412474 < option value = "absDelta" > Absolute delta</ option >
413- </ SortOrderDropdown >
475+ </ Dropdown >
414476 < Table >
415477 < thead >
416478 < HeaderTR >
@@ -440,9 +502,9 @@ export function ComparePerformance(_: Record<string, never>) {
440502 < ChevronCell >
441503 < Chevron expanded = { expandedPredicates . has ( row . name ) } />
442504 </ ChevronCell >
443- { renderAbsoluteValue ( row . before ) }
444- { renderAbsoluteValue ( row . after ) }
445- { renderDelta ( row . diff ) }
505+ { renderAbsoluteValue ( row . before , metric ) }
506+ { renderAbsoluteValue ( row . after , metric ) }
507+ { renderDelta ( row . diff , metric . unit ) }
446508 < NameCell > { rowNames [ rowIndex ] } </ NameCell >
447509 </ PredicateTR >
448510 { expandedPredicates . has ( row . name ) && (
0 commit comments