@@ -19,61 +19,56 @@ import sys
19
19
20
20
DRIVER_LIBRARY_PATH = "@PATH_TO_DRIVER_LIBRARY@"
21
21
sys .path .append (DRIVER_LIBRARY_PATH )
22
- DTRACE_PATH = os .path .join (DRIVER_LIBRARY_PATH , ' swift_stats.d' )
22
+ DTRACE_PATH = os .path .join (DRIVER_LIBRARY_PATH , " swift_stats.d" )
23
23
24
24
import perf_test_driver # noqa (E402 module level import not at top of file)
25
25
26
26
# Regexes for the XFAIL_LIST. Matches against '([Onone|O|Osize],TestName)'
27
- XFAIL_LIST = [
28
- ]
27
+ XFAIL_LIST = []
29
28
30
29
31
30
class DTraceResult (perf_test_driver .Result ):
32
-
33
31
def __init__ (self , name , status , output , csv_output ):
34
- perf_test_driver .Result .__init__ (
35
- self , name , status , output , XFAIL_LIST )
32
+ perf_test_driver .Result .__init__ (self , name , status , output , XFAIL_LIST )
36
33
self .csv_output = csv_output
37
34
38
35
def is_failure (self ):
39
36
return not bool (self .status )
40
37
41
38
@classmethod
42
39
def data_headers (cls ):
43
- return [
44
- 'Name' , 'Result' , 'Total RR Opts' , 'Total RR Opts/Iter' ]
40
+ return ["Name" , "Result" , "Total RR Opts" , "Total RR Opts/Iter" ]
45
41
46
42
@classmethod
47
43
def data_format (cls , max_test_len ):
48
44
non_name_headers = DTraceResult .data_headers ()[1 :]
49
- fmt = ('{:<%d}' % (max_test_len + 5 )) + \
50
- '' .join (['{:<%d}' % (len (h ) + 2 ) for h in non_name_headers ])
45
+ fmt = ("{:<%d}" % (max_test_len + 5 )) + "" .join (
46
+ ["{:<%d}" % (len (h ) + 2 ) for h in non_name_headers ]
47
+ )
51
48
return fmt
52
49
53
50
@classmethod
54
51
def print_data_header (cls , max_test_len , csv_output ):
55
52
headers = cls .data_headers ()
56
53
if csv_output :
57
- print (',' .join (headers ))
54
+ print ("," .join (headers ))
58
55
return
59
56
print (cls .data_format (max_test_len ).format (* headers ))
60
57
61
58
def print_data (self , max_test_len ):
62
59
result = [self .get_name (), self .get_result ()] + map (str , self .output )
63
60
if self .csv_output :
64
- print (',' .join (result ))
61
+ print ("," .join (result ))
65
62
return
66
63
67
64
print (DTraceResult .data_format (max_test_len ).format (* result ))
68
65
69
66
70
67
class DTraceBenchmarkDriver (perf_test_driver .BenchmarkDriver ):
71
-
72
68
def __init__ (self , binary , xfail_list , csv_output ):
73
69
perf_test_driver .BenchmarkDriver .__init__ (
74
- self , binary , xfail_list ,
75
- enable_parallel = True ,
76
- opt_levels = ['O' ])
70
+ self , binary , xfail_list , enable_parallel = True , opt_levels = ["O" ]
71
+ )
77
72
self .csv_output = csv_output
78
73
79
74
def print_data_header (self , max_test_len ):
@@ -83,23 +78,37 @@ class DTraceBenchmarkDriver(perf_test_driver.BenchmarkDriver):
83
78
return {}
84
79
85
80
def process_input (self , data ):
86
- test_name = ' ({}_{})' .format (data [' opt' ], data [' test_name' ])
81
+ test_name = " ({}_{})" .format (data [" opt" ], data [" test_name" ])
87
82
print ("Running {}..." .format (test_name ))
88
83
sys .stdout .flush ()
89
84
90
85
def get_results_with_iters (iters ):
91
86
e = os .environ
92
- e ['SWIFT_DETERMINISTIC_HASHING' ] = '1'
93
- p = subprocess .Popen ([
94
- 'sudo' , 'dtrace' , '-s' , DTRACE_PATH ,
95
- '-c' , '%s %s %s %s' % (data ['path' ], data ['test_name' ],
96
- '--num-iters=%d' % iters ,
97
- '--num-samples=2' )
98
- ], stdout = subprocess .PIPE , stderr = open ('/dev/null' , 'w' ), env = e )
87
+ e ["SWIFT_DETERMINISTIC_HASHING" ] = "1"
88
+ p = subprocess .Popen (
89
+ [
90
+ "sudo" ,
91
+ "dtrace" ,
92
+ "-s" ,
93
+ DTRACE_PATH ,
94
+ "-c" ,
95
+ "%s %s %s %s"
96
+ % (
97
+ data ["path" ],
98
+ data ["test_name" ],
99
+ "--num-iters=%d" % iters ,
100
+ "--num-samples=2" ,
101
+ ),
102
+ ],
103
+ stdout = subprocess .PIPE ,
104
+ stderr = open ("/dev/null" , "w" ),
105
+ env = e ,
106
+ )
99
107
results = [x for x in p .communicate ()[0 ].split ("\n " ) if len (x ) > 0 ]
100
108
return [
101
- x .split (',' )[1 ] for x in
102
- results [results .index ('DTRACE RESULTS' ) + 1 :]]
109
+ x .split ("," )[1 ] for x in results [results .index ("DTRACE RESULTS" ) + 1 :]
110
+ ]
111
+
103
112
iter_2_results = get_results_with_iters (2 )
104
113
iter_3_results = get_results_with_iters (3 )
105
114
iter_5_results = get_results_with_iters (5 )
@@ -136,16 +145,18 @@ SWIFT_BIN_DIR = os.path.dirname(os.path.abspath(__file__))
136
145
def parse_args ():
137
146
parser = argparse .ArgumentParser ()
138
147
parser .add_argument (
139
- ' -filter' ,
148
+ " -filter" ,
140
149
type = str ,
141
150
default = None ,
142
- help = 'Filter out any test that does not match the given regex' )
151
+ help = "Filter out any test that does not match the given regex" ,
152
+ )
143
153
parser .add_argument (
144
- ' --emit-csv' ,
154
+ " --emit-csv" ,
145
155
default = False ,
146
- action = ' store_true' ,
156
+ action = " store_true" ,
147
157
help = "Emit csv output" ,
148
- dest = 'csv_output' )
158
+ dest = "csv_output" ,
159
+ )
149
160
return parser .parse_args ()
150
161
151
162
0 commit comments