def complete_task(self, type, begin, end): if self.args.distinct: if self.last_task == (type, begin, end): return self.last_task = (type, begin, end) assert (GoogleTrace.Phase.has_key(type)) if begin['type'] == 7: # frame_begin begin['id'] = begin['tid'] if begin.has_key('tid') else 0 # Async events are groupped by cat & id res = self.format_task('b', 'frame', begin, {}) res += [',\n'] end_begin = begin.copy() end_begin['time'] = end['time'] res += self.format_task('e', 'frame', end_begin, {}) else: res = self.format_task(GoogleTrace.Phase[type], type, begin, end) if not res: return if type in ['task', 'counter'] and begin.has_key('data') and begin.has_key('str'): # FIXME: move closer to the place where stack is demanded self.handle_stack(begin, resolve_stack(self.args, self.tree, begin['data']), begin['str']) if self.args.debug and begin['type'] != 7: res = "".join(res) try: json.loads(res) except Exception as exc: print "\n" + exc.message + ":\n" + res + "\n" res += ',\n' else: res = "".join(res + [',\n']) self.file.write(res) if self.file.tell() > MAX_GT_SIZE: self.finish() self.start_new_trace()
def complete_task(self, type, begin, end): if self.args.distinct: if self.last_task == (type, begin, end): return self.last_task = (type, begin, end) assert (GoogleTrace.Phase.has_key(type)) if begin['type'] == 7: # frame_begin begin['id'] = begin['tid'] if begin.has_key('tid') else 0 # Async events are groupped by cat & id res = self.format_task('b', 'frame', begin, {}) res += [',\n'] end_begin = begin.copy() end_begin['time'] = end['time'] res += self.format_task('e', 'frame', end_begin, {}) else: res = self.format_task(GoogleTrace.Phase[type], type, begin, end) if not res: return if type in ['task', 'counter'] and begin.has_key('data') and begin.has_key('str'): #FIXME: move closer to the place where stack is demanded self.handle_stack(begin, resolve_stack(self.args, self.tree, begin['data']), begin['str']) if self.args.debug and begin['type'] != 7: res = "".join(res) try: json.loads(res) except Exception as exc: print "\n" + exc.message + ":\n" + res + "\n" res += ',\n' else: res = "".join(res + [',\n']) self.file.write(res) if (self.file.tell() > MAX_GT_SIZE): self.finish() self.start_new_trace()
def complete_task(self, type, begin, end): if self.args.distinct: if self.last_task == (type, begin, end): return self.last_task = (type, begin, end) assert (type in GoogleTrace.Phase) if begin['type'] == 7: # frame_begin if 'id' not in begin: begin['id'] = id( begin) # Async events are groupped by cat & id res = self.format_task('b', 'frame', begin, {}) if end: res += [',\n'] end_begin = begin.copy() end_begin['time'] = end['time'] - 1000 if 'args' in end: end_begin['args'] = end['args'] res += self.format_task('e', 'frame', end_begin, {}) else: res = self.format_task(GoogleTrace.Phase[type], type, begin, end) if not res: return if type in [ 'task', 'counter' ] and 'data' in begin and 'str' in begin: # FIXME: move closer to the place where stack is demanded self.handle_stack( begin, resolve_stack(self.args, self.tree, begin['data']), '%s:%s' % (begin['domain'], type)) if self.args.debug and begin['type'] != 7: res = "".join(res) try: json.loads(res) except Exception as exc: import traceback print("\n" + exc.message + ":\n" + res + "\n") traceback.print_stack() self.format_task(GoogleTrace.Phase[type], type, begin, end) res += ',\n' else: res = "".join(res + [',\n']) self.file.write(res) if self.file.tell() > MAX_GT_SIZE: self.finish(intermediate=True) self.start_new_trace() message('warning', 'Chrome Trace File Limit Exceeded on %d' % end['time'])