@@ -133,16 +133,6 @@ def prprint(s):
133
133
134
134
def pre_hook ():
135
135
import gc
136
- gc .collect ()
137
-
138
- try :
139
- from ctypes import cdll , CDLL
140
- cdll .LoadLibrary ("libc.so.6" )
141
- libc = CDLL ("libc.so.6" )
142
- libc .malloc_trim (0 )
143
- except :
144
- pass
145
-
146
136
gc .disable ()
147
137
148
138
def post_hook ():
@@ -231,36 +221,49 @@ def profile_comparative(benchmarks):
231
221
232
222
233
223
def profile_head_single (benchmark ):
224
+ import gc
234
225
results = []
235
226
227
+ # just in case
228
+ gc .collect ()
229
+
230
+ try :
231
+ from ctypes import cdll , CDLL
232
+ cdll .LoadLibrary ("libc.so.6" )
233
+ libc = CDLL ("libc.so.6" )
234
+ libc .malloc_trim (0 )
235
+ except :
236
+ pass
237
+
236
238
237
239
N = args .hrepeats + args .burnin
238
240
239
241
results = []
240
- for i in range (N ):
241
- pre_hook () # gc collect then disable
242
-
243
- d = dict ()
244
- sys .stdout .write ('.' )
245
- sys .stdout .flush ()
246
- try :
247
- d = benchmark .run ()
248
-
249
- except KeyboardInterrupt :
250
- raise
251
- except Exception as e : # if a single vbench bursts into flames, don't die.
252
- err = ""
253
- try :
254
- err = d .get ("traceback" )
255
- if err is None :
256
- err = str (e )
257
- except :
258
- pass
259
- print ("%s died with:\n %s\n Skipping...\n " % (benchmark .name , err ))
242
+ try :
243
+ for i in range (N ):
244
+ gc .disable ()
245
+ d = dict ()
260
246
261
- results .append (d .get ('timing' ,np .nan ))
247
+ try :
248
+ d = benchmark .run ()
249
+
250
+ except KeyboardInterrupt :
251
+ raise
252
+ except Exception as e : # if a single vbench bursts into flames, don't die.
253
+ err = ""
254
+ try :
255
+ err = d .get ("traceback" )
256
+ if err is None :
257
+ err = str (e )
258
+ except :
259
+ pass
260
+ print ("%s died with:\n %s\n Skipping...\n " % (benchmark .name , err ))
261
+
262
+ results .append (d .get ('timing' ,np .nan ))
263
+ gc .enable ()
262
264
263
- post_hook () # gc enable
265
+ finally :
266
+ gc .enable ()
264
267
265
268
if results :
266
269
# throw away the burn_in
0 commit comments