Created
March 23, 2017 13:32
-
-
Save ikhlestov/3d43b26ad4f9ff31fae3f2aa0b6c22c9 to your computer and use it in GitHub Desktop.
03_Profiling Tensorflow with timeline(only class for merging timelines)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
class TimeLiner: | |
_timeline_dict = None | |
def update_timeline(self, chrome_trace): | |
# convert crome trace to python dict | |
chrome_trace_dict = json.loads(chrome_trace) | |
# for first run store full trace | |
if self._timeline_dict is None: | |
self._timeline_dict = chrome_trace_dict | |
# for other - update only time consumption, not definitions | |
else: | |
for event in chrome_trace_dict['traceEvents']: | |
# events time consumption started with 'ts' prefix | |
if 'ts' in event: | |
self._timeline_dict['traceEvents'].append(event) | |
def save(self, f_name): | |
with open(f_name, 'w') as f: | |
json.dump(self._timeline_dict, f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment