@@ -289,7 +289,7 @@ <h1>Comparing <span id="stat-header">instructions:u</span> between <span id="bef
289
289
v-bind:class ="percentClass(bench.maxPct) "> {{bench.maxPct}}%{{isDodgyBench(bench)
290
290
? "?" : ""}}</ span > </ td >
291
291
</ tr >
292
- < template v-for ="run in bench.fields ">
292
+ < template v-for ="run in bench.variants ">
293
293
< tr >
294
294
< td > {{ run.casename }}</ td >
295
295
< td >
@@ -364,19 +364,19 @@ <h1>Comparing <span id="stat-header">instructions:u</span> between <span id="bef
364
364
data : null
365
365
} ,
366
366
computed : {
367
- notContinuous : function ( ) {
367
+ notContinuous ( ) {
368
368
return ! this . data . is_contiguous ;
369
369
} ,
370
- prevLink : function ( ) {
370
+ prevLink ( ) {
371
371
return `/compare.html?start=${ this . data . prev } &end=${ this . data . a . commit } ` ;
372
372
} ,
373
- nextLink : function ( ) {
373
+ nextLink ( ) {
374
374
return `/compare.html?start=${ this . data . b . commit } &end=${ this . data . next } ` ;
375
375
} ,
376
- compareLink : function ( ) {
376
+ compareLink ( ) {
377
377
return `https://github.com/rust-lang/rust/compare/${ this . data . a . commit } ...${ this . data . b . commit } ` ;
378
378
} ,
379
- benches : function ( ) {
379
+ benches ( ) {
380
380
let data = this . data ;
381
381
const filter = this . filter ;
382
382
@@ -394,101 +394,51 @@ <h1>Comparing <span id="stat-header">instructions:u</span> between <span id="bef
394
394
return true ;
395
395
}
396
396
}
397
- function toFields ( name ) {
398
- let source = data . a . data [ name ] || data . b . data [ name ] ;
399
- let maxLength = 0 ;
400
- if ( data . a . data [ name ] ) {
401
- maxLength = data . a . data [ name ] . length ;
402
- }
403
- if ( data . b . data [ name ] && data . b . data [ name ] . length > maxLength ) {
404
- maxLength = data . b . data [ name ] . length ;
405
- }
406
-
407
- let keys = { } ;
408
- if ( data . a . data [ name ] ) {
409
- for ( let i = 0 ; i < data . a . data [ name ] . length ; i ++ ) {
410
- if ( ! keys [ data . a . data [ name ] [ i ] [ 0 ] ] ) {
411
- keys [ data . a . data [ name ] [ i ] [ 0 ] ] = { } ;
412
- }
413
- keys [ data . a . data [ name ] [ i ] [ 0 ] ] . aIdx = i ;
414
- }
415
- }
416
- if ( data . b . data [ name ] ) {
417
- for ( let i = 0 ; i < data . b . data [ name ] . length ; i ++ ) {
418
- if ( ! keys [ data . b . data [ name ] [ i ] [ 0 ] ] ) {
419
- keys [ data . b . data [ name ] [ i ] [ 0 ] ] = { } ;
420
- }
421
- keys [ data . b . data [ name ] [ i ] [ 0 ] ] . bIdx = i ;
422
- }
423
- }
424
-
425
- let fields = [ ] ;
426
- for ( let key in keys ) {
427
- let aIdx = keys [ key ] . aIdx ;
428
- let bIdx = keys [ key ] . bIdx ;
429
- let datumA = null ;
430
- let datumB = null ;
431
- if ( aIdx != undefined && bIdx != undefined ) {
432
- datumA = data . a . data [ name ] [ aIdx ] [ 1 ] ;
433
- datumB = data . b . data [ name ] [ bIdx ] [ 1 ] ;
434
- } else if ( aIdx != undefined ) {
435
- datumA = data . a . data [ name ] [ aIdx ] [ 1 ] ;
436
- } else if ( bIdx != undefined ) {
437
- datumB = data . b . data [ name ] [ bIdx ] [ 1 ] ;
438
- } else {
439
- // should be unreachable
440
- }
441
-
442
-
443
- function percentChg ( a , b ) {
444
- if ( a && b ) {
445
- return 100 * ( b - a ) / a ;
446
- } else {
447
- return null ;
448
- }
449
- }
397
+ function toVariants ( name ) {
398
+ let variants = [ ] ;
399
+ for ( let d of data . a . data [ name ] ) {
400
+ const key = d [ 0 ] ;
401
+ const datumA = d [ 1 ] ;
402
+ const datumB = data . b . data [ name ] . find ( x => x [ 0 ] == key ) [ 1 ] ;
450
403
451
404
let isDodgy = false ;
452
405
if ( data . variance ) {
453
406
let variance = data . variance [ name + "-" + key ] ;
454
407
isDodgy = ! ! ( variance && variance . description && variance . description . type != "Normal" ) ;
455
408
}
456
409
if ( shouldShowBuild ( key ) ) {
457
- fields . push ( {
410
+ variants . push ( {
458
411
casename : key ,
459
412
datumA,
460
413
datumB,
461
- percent : percentChg ( datumA , datumB ) . toFixed ( 1 ) ,
414
+ percent : ( 100 * ( datumB - datumA ) / datumA ) . toFixed ( 1 ) ,
462
415
isDodgy,
463
416
} ) ;
464
417
}
465
418
}
466
419
467
- return fields ;
420
+ return variants ;
468
421
}
469
422
470
- let textNames = unique ( [
471
- ...Object . keys ( data . a . data ) ,
472
- ...Object . keys ( data . b . data ) ,
473
- ] ) ;
474
-
475
- let fields =
476
- textNames .
423
+ let benches =
424
+ Object . keys ( data . a . data ) .
477
425
filter ( n => filter . name && filter . name . trim ( ) ? n . includes ( filter . name . trim ( ) ) : true ) .
478
- map ( name => { return { name, fields : toFields ( name ) } } ) . filter ( b => b . fields . length > 0 ) ;
426
+ map ( name => { return { name, variants : toVariants ( name ) } } ) . filter ( b => b . variants . length > 0 ) ;
479
427
480
- for ( let field of fields ) {
481
- let pcts = field . fields . map ( field => parseFloat ( field . percent ) )
428
+ for ( let bench of benches ) {
429
+ let pcts = bench . variants . map ( field => parseFloat ( field . percent ) )
482
430
. filter ( p => p != undefined && p != null ) ;
483
- field . maxPct = Math . max ( ...pcts ) . toFixed ( 1 ) ;
484
- field . minPct = Math . min ( ...pcts ) . toFixed ( 1 ) ;
431
+ bench . maxPct = Math . max ( ...pcts ) . toFixed ( 1 ) ;
432
+ bench . minPct = Math . min ( ...pcts ) . toFixed ( 1 ) ;
485
433
let sum = pcts . reduce ( ( a , b ) => a + b , 0 ) ;
486
- let avg = sum / pcts . length ;
487
- field . avgPct = avg . toFixed ( 1 ) ;
488
- field . maxCasenameLen = Math . max ( ...field . fields . map ( f => f . casename . length ) ) ;
434
+ bench . avgPct = ( sum / pcts . length ) . toFixed ( 1 ) ;
435
+ bench . maxCasenameLen = Math . max ( ...bench . variants . map ( f => f . casename . length ) ) ;
489
436
}
437
+ const largestChange = a => Math . max ( Math . abs ( a . minPct ) , Math . abs ( a . maxPct ) ) ;
490
438
491
- return fields ;
439
+ benches . sort ( ( a , b ) => largestChange ( b ) - largestChange ( a ) ) ;
440
+
441
+ return benches ;
492
442
} ,
493
443
bootstrapTotals ( ) {
494
444
const sum = bootstrap => Object . entries ( bootstrap ) . map ( e => e [ 1 ] / 1e9 ) . reduce ( ( sum , next ) => sum + next , 0 ) ;
@@ -513,13 +463,13 @@ <h1>Comparing <span id="stat-header">instructions:u</span> between <span id="bef
513
463
} ,
514
464
} ,
515
465
methods : {
516
- short : function ( comparison ) {
466
+ short ( comparison ) {
517
467
return shortCommit ( comparison . commit ) ;
518
468
} ,
519
- prLink : function ( pr ) {
469
+ prLink ( pr ) {
520
470
return `https://github.com/rust-lang/rust/pull/${ pr } ` ;
521
471
} ,
522
- percentClass : function ( pct ) {
472
+ percentClass ( pct ) {
523
473
let klass = "" ;
524
474
if ( pct > 1 ) {
525
475
klass = 'positive' ;
@@ -560,11 +510,11 @@ <h1>Comparing <span id="stat-header">instructions:u</span> between <span id="bef
560
510
return result ;
561
511
} ,
562
512
isDodgyBench ( bench ) {
563
- return bench . fields . some ( f => f . isDodgy ) ;
513
+ return bench . variants . some ( f => f . isDodgy ) ;
564
514
} ,
565
515
} ,
566
516
watch : {
567
- data : function ( newVal , oldVal ) {
517
+ data ( newVal , oldVal ) {
568
518
if ( newVal && ! oldVal ) {
569
519
this . $nextTick ( ( ) => {
570
520
for ( let element of document . querySelectorAll ( ".toggle-table" ) ) {
@@ -574,7 +524,8 @@ <h1>Comparing <span id="stat-header">instructions:u</span> between <span id="bef
574
524
}
575
525
}
576
526
}
577
- } )
527
+ } ) ;
528
+
578
529
function toggleBenchGroup ( element ) {
579
530
let next = element . parentElement . parentElement . nextElementSibling ;
580
531
let inBody = [ ]
@@ -587,6 +538,7 @@ <h1>Comparing <span id="stat-header">instructions:u</span> between <span id="bef
587
538
next = next . nextElementSibling ;
588
539
}
589
540
}
541
+
590
542
function toggleFilters ( id , toggle ) {
591
543
let styles = document . getElementById ( id ) . style ;
592
544
let indicator = document . getElementById ( toggle ) ;
@@ -608,12 +560,10 @@ <h1>Comparing <span id="stat-header">instructions:u</span> between <span id="bef
608
560
toggleFilters ( "search-content" , "search-toggle-indicator" ) ;
609
561
} ;
610
562
611
-
612
563
function unique ( arr ) {
613
564
return arr . filter ( ( value , idx ) => arr . indexOf ( value ) == idx ) ;
614
565
}
615
566
616
-
617
567
function shortCommit ( commit ) {
618
568
return commit . substring ( 0 , 8 ) ;
619
569
}
@@ -638,6 +588,7 @@ <h1>Comparing <span id="stat-header">instructions:u</span> between <span id="bef
638
588
b && ( document . getElementById ( "after" ) . innerHTML = shorten ( b ) ) ;
639
589
stat && ( document . getElementById ( "stat-header" ) . innerHTML = stat ) ;
640
590
}
591
+
641
592
function findQueryParam ( name ) {
642
593
let urlParams = window . location . search . substring ( 1 ) . split ( "&" ) . map ( x => x . split ( "=" ) ) ;
643
594
let pair = urlParams . find ( x => x [ 0 ] === name )
0 commit comments