@@ -125,7 +125,7 @@ def get_benchmark_longitudinal_plot_config():
125125 plot = cfg .get ("benchmark_longitudinal_plot" , {})
126126 assert "base" in plot
127127 assert "version" in plot
128- assert "runner " in plot
128+ assert "runners " in plot
129129 if "head_flags" not in plot :
130130 plot ["head_flags" ] = []
131131 else :
@@ -548,7 +548,9 @@ def benchmark_longitudinal_plot(
548548
549549 cfg = get_benchmark_longitudinal_plot_config ()
550550
551- results = [r for r in results if r .fork == "python" and r .nickname == cfg ["runner" ]]
551+ results = [
552+ r for r in results if r .fork == "python" and r .nickname in cfg ["runners" ]
553+ ]
552554
553555 base = None
554556 for r in results :
@@ -564,7 +566,7 @@ def benchmark_longitudinal_plot(
564566 if r .version .startswith (cfg ["version" ]) and r .flags == cfg ["head_flags" ]
565567 ]
566568
567- by_benchmark = defaultdict (list )
569+ by_benchmark = defaultdict (lambda : defaultdict ( list ) )
568570 for r in results :
569571 if r .filename .name not in cache :
570572 comparison = result .BenchmarkComparison (base , r , "" )
@@ -579,12 +581,16 @@ def benchmark_longitudinal_plot(
579581 cache [r .filename .name ][name ] = value
580582
581583 for name , value in cache [r .filename .name ].items ():
582- by_benchmark [name ].append (value )
584+ by_benchmark [name ][ r . nickname ] .append (value )
583585
584586 with cache_filename .open ("w" ) as fd :
585587 json .dump (cache , fd , indent = 2 )
586588
587- by_benchmark = {k : v for k , v in by_benchmark .items () if len (v ) > 2 }
589+ # Exclude any benchmarks where we don't have enough data to make a
590+ # meaningful plot
591+ by_benchmark = {
592+ k : v for k , v in by_benchmark .items () if any (len (x ) > 2 for x in v .values ())
593+ }
588594
589595 fig , axs = plt .subplots (
590596 len (by_benchmark ),
@@ -599,10 +605,21 @@ def benchmark_longitudinal_plot(
599605 f"Performance change by benchmark on { cfg ['version' ]} vs. { cfg ['base' ]} "
600606 )
601607
602- for (benchmark , timings ), ax in zip (sorted (by_benchmark .items ()), axs ):
603- timings .sort (key = lambda x : datetime .datetime .fromisoformat (x [0 ]))
604- dates = [datetime .datetime .fromisoformat (x [0 ]) for x in timings ]
605- ax .plot (dates , [x [1 ] for x in timings ])
608+ first = True
609+ for (benchmark , runners ), ax in zip (sorted (by_benchmark .items ()), axs ):
610+ for runner_name , timings in runners .items ():
611+ runner = mrunners .get_runner_by_nickname (runner_name )
612+ timings .sort (key = lambda x : datetime .datetime .fromisoformat (x [0 ]))
613+ dates = [datetime .datetime .fromisoformat (x [0 ]) for x in timings ]
614+ ax .plot (
615+ dates ,
616+ [x [1 ] for x in timings ],
617+ label = runner .plot .name ,
618+ color = runner .plot .color ,
619+ linestyle = runner .plot .style ,
620+ marker = runner .plot .marker ,
621+ markersize = 2 ,
622+ )
606623 ax .set_xticks ([])
607624 ax .set_ylabel (benchmark , rotation = 0 , horizontalalignment = "right" )
608625 ax .yaxis .set_major_formatter (formatter )
@@ -611,6 +628,9 @@ def benchmark_longitudinal_plot(
611628 ax .grid (True , axis = "y" )
612629 ax .axhline (1.0 , color = "#666" , linestyle = "-" )
613630 ax .set_facecolor ("#f0f0f0" )
631+ if first :
632+ ax .legend (loc = "upper left" )
633+ first = False
614634
615635 savefig (output_filename , dpi = 150 )
616636
0 commit comments