@@ -26,20 +26,6 @@ import perf_test_driver
26
26
XFAIL_LIST = [
27
27
]
28
28
29
- # A list of Functions mapped to the number of globals in that function. These
30
- # show up as leaks. But we can count them, whitelist them, and then ignore them.
31
- FUNC_TO_GLOBAL_COUNTS = {
32
- 'Ackermann' : {"swift_count" : 1 , "objc_count" : 0 },
33
- 'AngryPhonebook' : {"swift_count" : 1 , "objc_count" : 0 },
34
- 'GlobalClass' : {'swift_count' : 1 , 'objc_count' : 0 },
35
- 'Histogram' : {'swift_count' : 1 , 'objc_count' : 0 },
36
- 'Phonebook' : {'swift_count' : 1 , 'objc_count' : 0 },
37
- 'RC4' : {'swift_count' : 1 , 'objc_count' : 0 },
38
- 'RGBHistogram' : {'swift_count' : 1 , 'objc_count' : 0 },
39
- 'SortStrings' : {'swift_count' : 1 , 'objc_count' : 0 },
40
- 'TwoSum' : {'swift_count' : 1 , 'objc_count' : 0 },
41
- }
42
-
43
29
# Global objective-c classes created by various frameworks. We do not care about these.
44
30
IGNORABLE_GLOBAL_OBJC_CLASSES = set ([
45
31
'__NSPlaceholderDate' ,
@@ -93,18 +79,15 @@ class LeaksRunnerBenchmarkDriver(perf_test_driver.BenchmarkDriver):
93
79
def prepare_input (self , name ):
94
80
return {'num_samples' : self .num_samples , 'num_iters' : self .num_iters }
95
81
96
- def process_input (self , data ):
97
- test_name = '({},{})' .format (data ['opt' ], data ['test_name' ])
98
- print ("Running {}..." .format (test_name ))
99
- sys .stdout .flush ()
82
+ def run_test (self , data , num_iters ):
100
83
try :
101
84
p = subprocess .Popen ([data ['path' ], "--run-all" , "--num-samples={}" .format (data ['num_samples' ]),
102
- "--num-iters={}" .format (data [ ' num_iters' ] ), data ['test_name' ]],
85
+ "--num-iters={}" .format (num_iters ), data ['test_name' ]],
103
86
stdout = subprocess .PIPE , stderr = subprocess .PIPE )
104
87
error_out = p .communicate ()[1 ].split ("\n " )
105
88
except OSError :
106
89
print ("Child Process Failed! (%s,%s)" % (data ['path' ], data ['test_name' ]))
107
- return LeaksRunnerResult ( test_name )
90
+ return None
108
91
109
92
try :
110
93
# We grab the second line since swift globals get lazily created in the
@@ -113,16 +96,24 @@ class LeaksRunnerBenchmarkDriver(perf_test_driver.BenchmarkDriver):
113
96
d ['objc_objects' ] = [x for x in d ['objc_objects' ] if x not in IGNORABLE_GLOBAL_OBJC_CLASSES ]
114
97
d ['objc_count' ] = len (d ['objc_objects' ])
115
98
116
- # Subtract out known global counts.
117
- if data ['test_name' ] in FUNC_TO_GLOBAL_COUNTS :
118
- d ['swift_count' ] -= FUNC_TO_GLOBAL_COUNTS [data ['test_name' ]]['swift_count' ]
119
- d ['objc_count' ] -= FUNC_TO_GLOBAL_COUNTS [data ['test_name' ]]['objc_count' ]
120
-
121
99
total_count = d ['objc_count' ] + d ['swift_count' ]
122
- return LeaksRunnerResult ( test_name , total_count )
100
+ return total_count
123
101
except (KeyError , ValueError ):
124
102
print ("Failed parse output! (%s,%s)" % (data ['path' ], data ['test_name' ]))
103
+ return None
104
+
105
+
106
+ def process_input (self , data ):
107
+ test_name = '({},{})' .format (data ['opt' ], data ['test_name' ])
108
+ print ("Running {}..." .format (test_name ))
109
+ sys .stdout .flush ()
110
+ total_count1 = self .run_test (data , data ['num_iters' ])
111
+ if total_count1 is None :
112
+ return LeaksRunnerResult (test_name )
113
+ total_count2 = self .run_test (data , data ['num_iters' ]+ 1 )
114
+ if total_count2 is None :
125
115
return LeaksRunnerResult (test_name )
116
+ return LeaksRunnerResult (test_name , total_count2 - total_count1 )
126
117
127
118
SWIFT_BIN_DIR = os .path .dirname (os .path .abspath (__file__ ))
128
119
0 commit comments