Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ikhlestov/3d43b26ad4f9ff31fae3f2aa0b6c22c9 to your computer and use it in GitHub Desktop.
Save ikhlestov/3d43b26ad4f9ff31fae3f2aa0b6c22c9 to your computer and use it in GitHub Desktop.
03_Profiling Tensorflow with timeline(only class for merging timelines)
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