@@ -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 className = { x > 0 ? "bad-value" : x < 0 ? "good-value" : "" } >
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 ) ;
@@ -198,7 +211,7 @@ const PipelineStepTR = styled.tr`
198211 }
199212` ;
200213
201- const SortOrderDropdown = styled . select `` ;
214+ const Dropdown = styled . select `` ;
202215
203216interface PipelineStepProps {
204217 before : number | undefined ;
@@ -287,6 +300,37 @@ function getSortOrder(sortOrder: "delta" | "absDelta") {
287300 return orderBy ( ( row : TRow ) => row . diff ) ;
288301}
289302
303+ interface Metric {
304+ title : string ;
305+ get ( info : PredicateInfo ) : number ;
306+ unit ?: string ;
307+ }
308+
309+ const metrics : Record < string , Metric > = {
310+ tuples : {
311+ title : "Tuples in pipeline" ,
312+ get : ( info ) => info . tuples ,
313+ } ,
314+ time : {
315+ title : "Time spent (milliseconds)" ,
316+ get : ( info ) => info . timeCost ,
317+ unit : "ms" ,
318+ } ,
319+ evaluations : {
320+ title : "Evaluations" ,
321+ get : ( info ) => info . evaluationCount ,
322+ } ,
323+ iterations : {
324+ title : "Iterations (per evaluation)" ,
325+ get : ( info ) =>
326+ info . absentReason ? 0 : info . iterationCount / info . evaluationCount ,
327+ } ,
328+ iterationsTotal : {
329+ title : "Iterations (total)" ,
330+ get : ( info ) => info . iterationCount ,
331+ } ,
332+ } ;
333+
290334function Chevron ( { expanded } : { expanded : boolean } ) {
291335 return < Codicon name = { expanded ? "chevron-down" : "chevron-right" } /> ;
292336}
@@ -332,6 +376,8 @@ export function ComparePerformance(_: Record<string, never>) {
332376
333377 const [ sortOrder , setSortOrder ] = useState < "delta" | "absDelta" > ( "absDelta" ) ;
334378
379+ const [ metric , setMetric ] = useState < Metric > ( metrics . tuples ) ;
380+
335381 if ( ! datasets ) {
336382 return < div > Loading performance comparison...</ div > ;
337383 }
@@ -349,7 +395,9 @@ export function ComparePerformance(_: Record<string, never>) {
349395 . map ( ( name ) => {
350396 const before = from . getTupleCountInfo ( name ) ;
351397 const after = to . getTupleCountInfo ( name ) ;
352- if ( before . tuples === after . tuples ) {
398+ const beforeValue = metric . get ( before ) ;
399+ const afterValue = metric . get ( after ) ;
400+ if ( beforeValue === afterValue ) {
353401 return undefined ! ;
354402 }
355403 if (
@@ -361,7 +409,7 @@ export function ComparePerformance(_: Record<string, never>) {
361409 return undefined ! ;
362410 }
363411 }
364- const diff = after . tuples - before . tuples ;
412+ const diff = afterValue - beforeValue ;
365413 return { name, before, after, diff } ;
366414 } )
367415 . filter ( ( x ) => ! ! x )
@@ -372,8 +420,8 @@ export function ComparePerformance(_: Record<string, never>) {
372420 let totalDiff = 0 ;
373421
374422 for ( const row of rows ) {
375- totalBefore += row . before . tuples ;
376- totalAfter += row . after . tuples ;
423+ totalBefore += metric . get ( row . before ) ;
424+ totalAfter += metric . get ( row . after ) ;
377425 totalDiff += row . diff ;
378426 }
379427
@@ -401,15 +449,28 @@ export function ComparePerformance(_: Record<string, never>) {
401449 </ label >
402450 </ WarningBox >
403451 ) }
404- < SortOrderDropdown
452+ Compare{ " " }
453+ < Dropdown
454+ onChange = { ( e : ChangeEvent < HTMLSelectElement > ) =>
455+ setMetric ( metrics [ e . target . value ] )
456+ }
457+ >
458+ { Object . entries ( metrics ) . map ( ( [ key , value ] ) => (
459+ < option key = { key } value = { key } >
460+ { value . title }
461+ </ option >
462+ ) ) }
463+ </ Dropdown > { " " }
464+ sorted by{ " " }
465+ < Dropdown
405466 onChange = { ( e : ChangeEvent < HTMLSelectElement > ) =>
406467 setSortOrder ( e . target . value as "delta" | "absDelta" )
407468 }
408469 value = { sortOrder }
409470 >
410471 < option value = "delta" > Delta</ option >
411472 < option value = "absDelta" > Absolute delta</ option >
412- </ SortOrderDropdown >
473+ </ Dropdown >
413474 < Table >
414475 < thead >
415476 < HeaderTR >
@@ -439,9 +500,9 @@ export function ComparePerformance(_: Record<string, never>) {
439500 < ChevronCell >
440501 < Chevron expanded = { expandedPredicates . has ( row . name ) } />
441502 </ ChevronCell >
442- { renderAbsoluteValue ( row . before ) }
443- { renderAbsoluteValue ( row . after ) }
444- { renderDelta ( row . diff ) }
503+ { renderAbsoluteValue ( row . before , metric ) }
504+ { renderAbsoluteValue ( row . after , metric ) }
505+ { renderDelta ( row . diff , metric . unit ) }
445506 < NameCell > { rowNames [ rowIndex ] } </ NameCell >
446507 </ PredicateTR >
447508 { expandedPredicates . has ( row . name ) && (
0 commit comments