@@ -26,7 +26,8 @@ import perf_test_driver
26
26
XFAIL_LIST = [
27
27
]
28
28
29
- # Global objective-c classes created by various frameworks. We do not care about these.
29
+ # Global objective-c classes created by various frameworks. We do not care about
30
+ # these.
30
31
IGNORABLE_GLOBAL_OBJC_CLASSES = set ([
31
32
'__NSPlaceholderDate' ,
32
33
'NSCache' ,
@@ -60,6 +61,7 @@ class LeaksRunnerResult(perf_test_driver.Result):
60
61
print (fmt .format (self .get_name (), self .get_result (),
61
62
self .get_count ()))
62
63
64
+
63
65
class LeaksRunnerBenchmarkDriver (perf_test_driver .BenchmarkDriver ):
64
66
65
67
def __init__ (self , binary , xfail_list , num_samples , num_iters ):
@@ -81,54 +83,61 @@ class LeaksRunnerBenchmarkDriver(perf_test_driver.BenchmarkDriver):
81
83
82
84
def run_test (self , data , num_iters ):
83
85
try :
84
- p = subprocess .Popen ([data ['path' ], "--run-all" , "--num-samples={}" .format (data ['num_samples' ]),
85
- "--num-iters={}" .format (num_iters ), data ['test_name' ]],
86
- stdout = subprocess .PIPE , stderr = subprocess .PIPE )
86
+ p = subprocess .Popen ([
87
+ data ['path' ], "--run-all" ,
88
+ "--num-samples={}" .format (data ['num_samples' ]),
89
+ "--num-iters={}" .format (num_iters ), data ['test_name' ]],
90
+ stdout = subprocess .PIPE , stderr = subprocess .PIPE )
87
91
error_out = p .communicate ()[1 ].split ("\n " )
88
92
except OSError :
89
- print ("Child Process Failed! (%s,%s)" % (data ['path' ], data ['test_name' ]))
93
+ print ("Child Process Failed! (%s,%s)" % (
94
+ data ['path' ], data ['test_name' ]))
90
95
return None
91
96
92
97
try :
93
- # We grab the second line since swift globals get lazily created in the
94
- # first iteration.
98
+ # We grab the second line since swift globals get lazily created in
99
+ # the first iteration.
95
100
d = json .loads (error_out [1 ])
96
- d ['objc_objects' ] = [x for x in d ['objc_objects' ] if x not in IGNORABLE_GLOBAL_OBJC_CLASSES ]
101
+ d ['objc_objects' ] = [x for x in d ['objc_objects' ]
102
+ if x not in IGNORABLE_GLOBAL_OBJC_CLASSES ]
97
103
d ['objc_count' ] = len (d ['objc_objects' ])
98
104
99
105
total_count = d ['objc_count' ] + d ['swift_count' ]
100
106
return total_count
101
107
except (KeyError , ValueError ):
102
- print ("Failed parse output! (%s,%s)" % (data ['path' ], data ['test_name' ]))
108
+ print ("Failed parse output! (%s,%s)" %
109
+ (data ['path' ], data ['test_name' ]))
103
110
return None
104
111
105
-
106
112
def process_input (self , data ):
107
113
test_name = '({},{})' .format (data ['opt' ], data ['test_name' ])
108
114
print ("Running {}..." .format (test_name ))
109
115
sys .stdout .flush ()
110
116
total_count1 = self .run_test (data , data ['num_iters' ])
111
117
if total_count1 is None :
112
118
return LeaksRunnerResult (test_name )
113
- total_count2 = self .run_test (data , data ['num_iters' ]+ 1 )
119
+ total_count2 = self .run_test (data , data ['num_iters' ] + 1 )
114
120
if total_count2 is None :
115
121
return LeaksRunnerResult (test_name )
116
122
return LeaksRunnerResult (test_name , total_count2 - total_count1 )
117
123
118
124
SWIFT_BIN_DIR = os .path .dirname (os .path .abspath (__file__ ))
119
125
126
+
120
127
def parse_args ():
121
128
import argparse
122
129
parser = argparse .ArgumentParser ()
123
- parser .add_argument ('-filter' , type = str , default = None ,
124
- help = 'Filter out any test that does not match the given regex' )
130
+ parser .add_argument (
131
+ '-filter' , type = str , default = None ,
132
+ help = 'Filter out any test that does not match the given regex' )
125
133
parser .add_argument ('-num-samples' , type = int , default = 2 )
126
134
parser .add_argument ('-num-iters' , type = int , default = 2 )
127
135
return parser .parse_args ()
128
136
129
137
if __name__ == "__main__" :
130
138
args = parse_args ()
131
- l = LeaksRunnerBenchmarkDriver (SWIFT_BIN_DIR , XFAIL_LIST , args .num_samples , args .num_iters )
139
+ l = LeaksRunnerBenchmarkDriver (
140
+ SWIFT_BIN_DIR , XFAIL_LIST , args .num_samples , args .num_iters )
132
141
if l .run (args .filter ):
133
142
sys .exit (0 )
134
143
else :
0 commit comments