##// END OF EJS Templates
statprof: require paths to save or load profile data...
Gregory Szorc -
r30255:f42cd543 default
parent child Browse files
Show More
@@ -311,13 +311,11 b' def stop():'
311 311 state.accumulate_time(clock())
312 312 state.last_start_time = None
313 313 statprofpath = os.environ.get('STATPROF_DEST')
314 save_data(statprofpath)
314 if statprofpath:
315 save_data(statprofpath)
315 316
316 def save_data(path=None):
317 try:
318 path = path or (os.environ['HOME'] + '/statprof.data')
319 file = open(path, "w+")
320
317 def save_data(path):
318 with open(path, 'w+') as file:
321 319 file.write(str(state.accumulated_time) + '\n')
322 320 for sample in state.samples:
323 321 time = str(sample.time)
@@ -326,13 +324,7 b' def save_data(path=None):'
326 324 for s in stack]
327 325 file.write(time + '\0' + '\0'.join(sites) + '\n')
328 326
329 file.close()
330 except (IOError, OSError):
331 # The home directory probably didn't exist, or wasn't writable. Oh well.
332 pass
333
334 def load_data(path=None):
335 path = path or (os.environ['HOME'] + '/statprof.data')
327 def load_data(path):
336 328 lines = open(path, 'r').read().splitlines()
337 329
338 330 state.accumulated_time = float(lines[0])
General Comments 0
You need to be logged in to leave comments. Login now