Show More
@@ -311,13 +311,11 b' def stop():' | |||||
311 | state.accumulate_time(clock()) |
|
311 | state.accumulate_time(clock()) | |
312 | state.last_start_time = None |
|
312 | state.last_start_time = None | |
313 | statprofpath = os.environ.get('STATPROF_DEST') |
|
313 | statprofpath = os.environ.get('STATPROF_DEST') | |
314 |
|
|
314 | if statprofpath: | |
|
315 | save_data(statprofpath) | |||
315 |
|
316 | |||
316 |
def save_data(path |
|
317 | def save_data(path): | |
317 | try: |
|
318 | with open(path, 'w+') as file: | |
318 | path = path or (os.environ['HOME'] + '/statprof.data') |
|
|||
319 | file = open(path, "w+") |
|
|||
320 |
|
||||
321 | file.write(str(state.accumulated_time) + '\n') |
|
319 | file.write(str(state.accumulated_time) + '\n') | |
322 | for sample in state.samples: |
|
320 | for sample in state.samples: | |
323 | time = str(sample.time) |
|
321 | time = str(sample.time) | |
@@ -326,13 +324,7 b' def save_data(path=None):' | |||||
326 | for s in stack] |
|
324 | for s in stack] | |
327 | file.write(time + '\0' + '\0'.join(sites) + '\n') |
|
325 | file.write(time + '\0' + '\0'.join(sites) + '\n') | |
328 |
|
326 | |||
329 | file.close() |
|
327 | def load_data(path): | |
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') |
|
|||
336 | lines = open(path, 'r').read().splitlines() |
|
328 | lines = open(path, 'r').read().splitlines() | |
337 |
|
329 | |||
338 | state.accumulated_time = float(lines[0]) |
|
330 | state.accumulated_time = float(lines[0]) |
General Comments 0
You need to be logged in to leave comments.
Login now