Mercurial > hg
comparison mercurial/statprof.py @ 38274:99188a7c8717
statprof: fix save and load
Fix these functions even if they don't are used at the moment. Thanks to Yuya
Nishihara for spotting that.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Mon, 11 Jun 2018 19:24:01 +0200 |
parents | 15a1e37f80bd |
children | 3c569172848d |
comparison
equal
deleted
inserted
replaced
38273:9df777d7f061 | 38274:99188a7c8717 |
---|---|
348 | 348 |
349 return state | 349 return state |
350 | 350 |
351 def save_data(path): | 351 def save_data(path): |
352 with open(path, 'w+') as file: | 352 with open(path, 'w+') as file: |
353 file.write(str(state.accumulated_time) + '\n') | 353 file.write("%f %f\n" % state.accumulated_time) |
354 for sample in state.samples: | 354 for sample in state.samples: |
355 time = str(sample.time) | 355 time = str(sample.time) |
356 stack = sample.stack | 356 stack = sample.stack |
357 sites = ['\1'.join([s.path, str(s.lineno), s.function]) | 357 sites = ['\1'.join([s.path, str(s.lineno), s.function]) |
358 for s in stack] | 358 for s in stack] |
359 file.write(time + '\0' + '\0'.join(sites) + '\n') | 359 file.write(time + '\0' + '\0'.join(sites) + '\n') |
360 | 360 |
361 def load_data(path): | 361 def load_data(path): |
362 lines = open(path, 'r').read().splitlines() | 362 lines = open(path, 'r').read().splitlines() |
363 | 363 |
364 state.accumulated_time = float(lines[0]) | 364 state.accumulated_time = [float(value) for value in lines[0].split()] |
365 state.samples = [] | 365 state.samples = [] |
366 for line in lines[1:]: | 366 for line in lines[1:]: |
367 parts = line.split('\0') | 367 parts = line.split('\0') |
368 time = float(parts[0]) | 368 time = float(parts[0]) |
369 rawsites = parts[1:] | 369 rawsites = parts[1:] |