@@ -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,20 +89,30 @@ 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
93- function renderDelta ( x : number ) {
101+ function renderDelta ( x : number , unit ?: string ) {
94102 const sign = x > 0 ? "+" : "" ;
95103 return (
96104 < NumberCell >
97105 { sign }
98106 { formatDecimal ( x ) }
107+ { renderUnit ( unit ) }
99108 </ NumberCell >
100109 ) ;
101110}
102111
112+ function renderUnit ( unit : string | undefined ) {
113+ return unit == null ? "" : ` ${ unit } ` ;
114+ }
115+
103116function orderBy < T > ( fn : ( x : T ) => number | string ) {
104117 return ( x : T , y : T ) => {
105118 const fx = fn ( x ) ;
@@ -185,7 +198,7 @@ const PipelineStepTR = styled.tr`
185198 }
186199` ;
187200
188- const SortOrderDropdown = styled . select `` ;
201+ const Dropdown = styled . select `` ;
189202
190203interface PipelineStepProps {
191204 before : number | undefined ;
@@ -274,6 +287,37 @@ function getSortOrder(sortOrder: "delta" | "absDelta") {
274287 return orderBy ( ( row : TRow ) => row . diff ) ;
275288}
276289
290+ interface Metric {
291+ title : string ;
292+ get ( info : PredicateInfo ) : number ;
293+ unit ?: string ;
294+ }
295+
296+ const metrics : Record < string , Metric > = {
297+ tuples : {
298+ title : "Tuples in pipeline" ,
299+ get : ( info ) => info . tuples ,
300+ } ,
301+ time : {
302+ title : "Time spent (milliseconds)" ,
303+ get : ( info ) => info . timeCost ,
304+ unit : "ms" ,
305+ } ,
306+ evaluations : {
307+ title : "Evaluations" ,
308+ get : ( info ) => info . evaluationCount ,
309+ } ,
310+ iterations : {
311+ title : "Iterations (per evaluation)" ,
312+ get : ( info ) =>
313+ info . absentReason ? 0 : info . iterationCount / info . evaluationCount ,
314+ } ,
315+ iterationsTotal : {
316+ title : "Iterations (total)" ,
317+ get : ( info ) => info . iterationCount ,
318+ } ,
319+ } ;
320+
277321function Chevron ( { expanded } : { expanded : boolean } ) {
278322 return < Codicon name = { expanded ? "chevron-down" : "chevron-right" } /> ;
279323}
@@ -319,6 +363,8 @@ export function ComparePerformance(_: Record<string, never>) {
319363
320364 const [ sortOrder , setSortOrder ] = useState < "delta" | "absDelta" > ( "delta" ) ;
321365
366+ const [ metric , setMetric ] = useState < Metric > ( metrics . tuples ) ;
367+
322368 if ( ! datasets ) {
323369 return < div > Loading performance comparison...</ div > ;
324370 }
@@ -336,7 +382,9 @@ export function ComparePerformance(_: Record<string, never>) {
336382 . map ( ( name ) => {
337383 const before = from . getTupleCountInfo ( name ) ;
338384 const after = to . getTupleCountInfo ( name ) ;
339- if ( before . tuples === after . tuples ) {
385+ const beforeValue = metric . get ( before ) ;
386+ const afterValue = metric . get ( after ) ;
387+ if ( beforeValue === afterValue ) {
340388 return undefined ! ;
341389 }
342390 if (
@@ -348,7 +396,7 @@ export function ComparePerformance(_: Record<string, never>) {
348396 return undefined ! ;
349397 }
350398 }
351- const diff = after . tuples - before . tuples ;
399+ const diff = afterValue - beforeValue ;
352400 return { name, before, after, diff } ;
353401 } )
354402 . filter ( ( x ) => ! ! x )
@@ -359,8 +407,8 @@ export function ComparePerformance(_: Record<string, never>) {
359407 let totalDiff = 0 ;
360408
361409 for ( const row of rows ) {
362- totalBefore += row . before . tuples ;
363- totalAfter += row . after . tuples ;
410+ totalBefore += metric . get ( row . before ) ;
411+ totalAfter += metric . get ( row . after ) ;
364412 totalDiff += row . diff ;
365413 }
366414
@@ -388,15 +436,28 @@ export function ComparePerformance(_: Record<string, never>) {
388436 </ label >
389437 </ WarningBox >
390438 ) }
391- < SortOrderDropdown
439+ Compare{ " " }
440+ < Dropdown
441+ onChange = { ( e : ChangeEvent < HTMLSelectElement > ) =>
442+ setMetric ( metrics [ e . target . value ] )
443+ }
444+ >
445+ { Object . entries ( metrics ) . map ( ( [ key , value ] ) => (
446+ < option key = { key } value = { key } >
447+ { value . title }
448+ </ option >
449+ ) ) }
450+ </ Dropdown > { " " }
451+ sorted by{ " " }
452+ < Dropdown
392453 onChange = { ( e : ChangeEvent < HTMLSelectElement > ) =>
393454 setSortOrder ( e . target . value as "delta" | "absDelta" )
394455 }
395456 value = { sortOrder }
396457 >
397458 < option value = "delta" > Delta</ option >
398459 < option value = "absDelta" > Absolute delta</ option >
399- </ SortOrderDropdown >
460+ </ Dropdown >
400461 < Table >
401462 < thead >
402463 < HeaderTR >
@@ -426,9 +487,9 @@ export function ComparePerformance(_: Record<string, never>) {
426487 < ChevronCell >
427488 < Chevron expanded = { expandedPredicates . has ( row . name ) } />
428489 </ ChevronCell >
429- { renderAbsoluteValue ( row . before ) }
430- { renderAbsoluteValue ( row . after ) }
431- { renderDelta ( row . diff ) }
490+ { renderAbsoluteValue ( row . before , metric ) }
491+ { renderAbsoluteValue ( row . after , metric ) }
492+ { renderDelta ( row . diff , metric . unit ) }
432493 < NameCell > { rowNames [ rowIndex ] } </ NameCell >
433494 </ PredicateTR >
434495 { expandedPredicates . has ( row . name ) && (
0 commit comments