66
77from matplotlib import pyplot as plt , lines
88import shelve
9- import json
10- import subprocess as subp
11- import sys
129from collections import defaultdict
1310from run_benchmarks import get_commits , run
1411import numpy as np
1916
2017commits , comments = get_commits ()
2118
19+
2220def get_benchmarks (results ):
2321 benchmarks = defaultdict (lambda : [])
2422 for hash in commits :
@@ -30,6 +28,7 @@ def get_benchmarks(results):
3028 benchmarks [name ].append ((commits .index (hash ), time ))
3129 return benchmarks
3230
31+
3332with shelve .open ("benchmark_results" ) as results :
3433 benchmarks = get_benchmarks (results )
3534
@@ -38,37 +37,44 @@ def get_benchmarks(results):
3837
3938plt .sca (ax [0 ])
4039for name , xy in benchmarks .items ():
41- if "uniform" in name : continue
40+ if "uniform" in name :
41+ continue
4242 if "_1d" in name :
4343 x , y = np .transpose (xy )
4444 plt .plot (x , y , ".-" , label = name )
4545plt .legend (fontsize = "xx-small" )
4646
4747plt .sca (ax [1 ])
4848for name , xy in benchmarks .items ():
49- if "uniform" in name : continue
49+ if "uniform" in name :
50+ continue
5051 if "_2d" in name :
5152 x , y = np .transpose (xy )
5253 plt .plot (x , y , ".-" , label = name )
5354plt .legend (fontsize = "xx-small" )
5455
5556plt .sca (ax [2 ])
5657for name , xy in benchmarks .items ():
57- if "uniform" in name : continue
58+ if "uniform" in name :
59+ continue
5860 if "_3d" in name :
5961 x , y = np .transpose (xy )
6062 plt .plot (x , y , ".-" , label = name )
6163plt .legend (fontsize = "xx-small" )
6264
6365plt .sca (ax [3 ])
6466for name , xy in benchmarks .items ():
65- if "uniform" in name : continue
67+ if "uniform" in name :
68+ continue
6669 if "_6d" in name :
6770 x , y = np .transpose (xy )
6871 plt .plot (x , y , ".-" , label = name )
6972plt .legend (fontsize = "xx-small" )
7073
71- plt .figtext (0.01 , 0.5 , "time per loop / ns [smaller is better]" , rotation = 90 , va = "center" )
74+ plt .figtext (
75+ 0.01 , 0.5 , "time per loop / ns [smaller is better]" , rotation = 90 , va = "center"
76+ )
77+
7278
7379def format_coord (x , y ):
7480 global current_index
@@ -77,14 +83,18 @@ def format_coord(x, y):
7783 comment = comments [hash ]
7884 return f"{ hash } { comment } "
7985
86+
8087for axi in ax .flatten ():
8188 axi .format_coord = format_coord
8289
90+
8391def on_key_press (event ):
8492 global thread
85- if thread and thread .is_alive (): return
93+ if thread and thread .is_alive ():
94+ return
8695
87- if event .key != "u" : return
96+ if event .key != "u" :
97+ return
8898
8999 hash = commits [current_index ]
90100
@@ -107,6 +117,7 @@ def worker(fig, ax, hash):
107117 thread = threading .Thread (target = worker , args = (fig , ax , hash ))
108118 thread .start ()
109119
110- fig .canvas .mpl_connect ('key_press_event' , on_key_press )
120+
121+ fig .canvas .mpl_connect ("key_press_event" , on_key_press )
111122
112123plt .show ()
0 commit comments