@@ -32,24 +32,32 @@ def create_time_series_chart(benchmarks: list[BenchmarkSeries], github_repo: str
3232
3333 num_benchmarks = len (benchmarks )
3434 if num_benchmarks == 0 :
35- return
35+ return []
3636
3737 html_charts = []
3838
3939 for _ , benchmark in enumerate (benchmarks ):
4040 fig , ax = plt .subplots (figsize = (10 , 4 ))
4141
42+ all_values = []
43+ all_stddevs = []
44+
4245 for run in benchmark .runs :
4346 sorted_points = sorted (run .results , key = lambda x : x .date )
4447 dates = [point .date for point in sorted_points ]
4548 values = [point .value for point in sorted_points ]
49+ stddevs = [point .stddev for point in sorted_points ]
50+
51+ all_values .extend (values )
52+ all_stddevs .extend (stddevs )
4653
47- ax .plot_date (dates , values , '-' , label = run .name , alpha = 0.5 )
54+ ax .errorbar (dates , values , yerr = stddevs , fmt = '-' , label = run .name , alpha = 0.5 )
4855 scatter = ax .scatter (dates , values , picker = True )
4956
5057 tooltip_labels = [
5158 f"Date: { point .date .strftime ('%Y-%m-%d %H:%M:%S' )} \n "
52- f"Value: { point .value :.2f} \n "
59+ f"Value: { point .value :.2f} { benchmark .metadata .unit } \n "
60+ f"Stddev: { point .stddev :.2f} { benchmark .metadata .unit } \n "
5361 f"Git Hash: { point .git_hash } "
5462 for point in sorted_points
5563 ]
@@ -62,6 +70,13 @@ def create_time_series_chart(benchmarks: list[BenchmarkSeries], github_repo: str
6270 targets = targets )
6371 mpld3 .plugins .connect (fig , tooltip )
6472
73+ # This is so that the stddev doesn't fill the entire y axis on the chart
74+ if all_values and all_stddevs :
75+ max_value = max (all_values )
76+ min_value = min (all_values )
77+ max_stddev = max (all_stddevs )
78+ ax .set_ylim (min_value - 3 * max_stddev , max_value + 3 * max_stddev )
79+
6580 ax .set_title (benchmark .label , pad = 20 )
6681 performance_indicator = "lower is better" if benchmark .metadata .lower_is_better else "higher is better"
6782 ax .text (0.5 , 1.05 , f"({ performance_indicator } )" ,
@@ -79,7 +94,7 @@ def create_time_series_chart(benchmarks: list[BenchmarkSeries], github_repo: str
7994 ax .xaxis .set_major_formatter (mdates .ConciseDateFormatter ('%Y-%m-%d %H:%M:%S' ))
8095
8196 plt .tight_layout ()
82- html_charts .append (BenchmarkTimeSeries (html = mpld3 .fig_to_html (fig ), label = benchmark .label ))
97+ html_charts .append (BenchmarkTimeSeries (html = mpld3 .fig_to_html (fig ), label = benchmark .label ))
8398 plt .close (fig )
8499
85100 return html_charts
0 commit comments