comparison mercurial/statprof.py @ 30299:1e5346313963

statprof: return state from stop() I don't like global variables. Have stop() return the captured state so callers can pass data to the display function.
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 04 Nov 2016 20:22:37 -0700
parents eea89068a98d
children bb35fe8621f5
comparison
equal deleted inserted replaced
30297:d4db88a26ad5 30299:1e5346313963
322 state.last_start_time = None 322 state.last_start_time = None
323 statprofpath = os.environ.get('STATPROF_DEST') 323 statprofpath = os.environ.get('STATPROF_DEST')
324 if statprofpath: 324 if statprofpath:
325 save_data(statprofpath) 325 save_data(statprofpath)
326 326
327 return state
328
327 def save_data(path): 329 def save_data(path):
328 with open(path, 'w+') as file: 330 with open(path, 'w+') as file:
329 file.write(str(state.accumulated_time) + '\n') 331 file.write(str(state.accumulated_time) + '\n')
330 for sample in state.samples: 332 for sample in state.samples:
331 time = str(sample.time) 333 time = str(sample.time)