20
20
from __future__ import annotations
21
21
22
22
import json
23
- import statistics
24
23
from dataclasses import dataclass
25
24
from typing import Dict , List , Any
26
25
from pathlib import Path
33
32
print ("Try `pip install rich` for using this script." )
34
33
raise
35
34
36
- MEAN_THRESHOLD = 5
37
-
38
35
39
36
@dataclass
40
37
class QueryResult :
@@ -64,14 +61,9 @@ def load_from(cls, data: Dict[str, Any]) -> QueryRun:
64
61
def execution_time (self ) -> float :
65
62
assert len (self .iterations ) >= 1
66
63
67
- # If we don't have enough samples, median() is probably
68
- # going to be a worse measure than just an average.
69
- if len (self .iterations ) < MEAN_THRESHOLD :
70
- method = statistics .mean
71
- else :
72
- method = statistics .median
73
-
74
- return method (iteration .elapsed for iteration in self .iterations )
64
+ # Use minimum execution time to account for variations / other
65
+ # things the system was doing
66
+ return min (iteration .elapsed for iteration in self .iterations )
75
67
76
68
77
69
@dataclass
@@ -81,7 +73,6 @@ class Context:
81
73
num_cpus : int
82
74
start_time : int
83
75
arguments : List [str ]
84
- branch : str
85
76
86
77
@classmethod
87
78
def load_from (cls , data : Dict [str , Any ]) -> Context :
@@ -91,7 +82,6 @@ def load_from(cls, data: Dict[str, Any]) -> Context:
91
82
num_cpus = data ["num_cpus" ],
92
83
start_time = data ["start_time" ],
93
84
arguments = data ["arguments" ],
94
- branch = data ["arguments" ][9 ]
95
85
)
96
86
97
87
@@ -119,17 +109,19 @@ def compare(
119
109
noise_threshold : float ,
120
110
) -> None :
121
111
baseline = BenchmarkRun .load_from_file (baseline_path )
122
- baselineBranch = baseline .context .branch
123
112
124
113
comparison = BenchmarkRun .load_from_file (comparison_path )
125
- comparisonBranch = comparison .context .branch
126
114
127
115
console = Console ()
128
116
117
+ # use basename as the column names
118
+ baseline_header = baseline_path .stem
119
+ comparison_header = comparison_path .stem
120
+
129
121
table = Table (show_header = True , header_style = "bold magenta" )
130
122
table .add_column ("Query" , style = "dim" , width = 12 )
131
- table .add_column (baselineBranch , justify = "right" , style = "dim" , width = 12 )
132
- table .add_column (comparisonBranch , justify = "right" , style = "dim" , width = 12 )
123
+ table .add_column (baseline_header , justify = "right" , style = "dim" )
124
+ table .add_column (comparison_header , justify = "right" , style = "dim" )
133
125
table .add_column ("Change" , justify = "right" , style = "dim" )
134
126
135
127
for baseline_result , comparison_result in zip (baseline .queries , comparison .queries ):
0 commit comments