def transform_dtrace(args): tree = default_tree() tree['ring_buffer'] = True TaskCombiner.disable_handling_leftovers = True gt = get_exporters()['gt'] with Callbacks(args, tree) as callbacks: if callbacks.is_empty(): return callbacks.get_result() dtrace = DTrace(args, gt, callbacks) with Progress(os.path.getsize(args.input), 50, "Parsing: " + os.path.basename(args.input)) as progress: count = 0 with open(args.input) as file: for line in file: line = line.strip() if not line: continue parts = line.split('\t') dtrace.handle_record(int(parts[0], 16), parts[1], parts[2:]) if not count % 1000: progress.tick(file.tell()) count += 1 dtrace.finalize() return callbacks.get_result() + dtrace.get_result()
def export_mem_stat(self): gt = get_exporters()['gt'](self.args, self.tree) total = self.mem_stat['total_max'] def export_node(name, node, offset): length = 1000000. * node['total_max'] / total call_data = { 'tid': 0, 'pid': 0, 'domain': 'memory', 'time': offset, 'str': name, 'type': 0 } end_data = call_data.copy() end_data['time'] = offset + length end_data['type'] = 1 gt.complete_task('task', call_data, end_data) for pair, child in node['children'].iteritems(): offset += export_node(pair[1], child, offset) return length export_node('global scope', self.mem_stat, 0) gt.finish() self.targets.append(gt.get_targets()[0])
def transform_dtrace(args): tree = default_tree(args) tree['ring_buffer'] = True args.no_left_overs = True gt = get_exporters()['gt'] with Callbacks(args, tree) as callbacks: if callbacks.is_empty(): return callbacks.get_result() dtrace = DTrace(args, gt, callbacks) size = os.path.getsize(args.input) with Progress( size, 50, "Parsing: %s (%s)" % (os.path.basename(args.input), format_bytes(size))) as progress: count = 0 with codecs.open(args.input, 'r', 'utf-8', errors='ignore') as file: reading_stack = None stack = [] for line in file: count += 1 ends_with_vt = (11 == ord( line[-1])) if len(line) else False #old_line = line line = line.strip('\r\n') #print "%d\t%s" % (count, line) if not line: if reading_stack: dtrace.handle_stack(*(reading_stack + [stack])) reading_stack = None stack = [] continue if reading_stack: if ends_with_vt: # Vertical Tab signifies too long stack frame description line += '...' end_of_line = file.readline( ) # it is also treated as line end by codecs.open line += end_of_line.strip() stack.append(line.replace('\t', ' ')) continue parts = line.split('\t') if len(parts) < 4: print("Warning: weird line:", line) continue if parts[1] in ['ustack', 'kstack', 'jstack']: reading_stack = [ parts[1], int(parts[0], 16), parts[2], parts[3].rstrip(':') ] continue dtrace.handle_record(int(parts[0], 16), parts[1], parts[2:]) if not count % 1000: progress.tick(file.tell()) dtrace.finalize() return callbacks.get_result()
def export_mem_stat(self): gt = get_exporters()['gt'](self.args, self.tree) total = self.mem_stat['total_max'] def export_node(name, node, offset): length = 1000000. * node['total_max'] / total call_data = {'tid': 0, 'pid': 0, 'domain': 'memory', 'time': offset, 'str': name, 'type': 0} end_data = call_data.copy() end_data['time'] = offset + length end_data['type'] = 1 gt.complete_task('task', call_data, end_data) for pair, child in node['children'].iteritems(): offset += export_node(pair[1], child, offset) return length export_node('global scope', self.mem_stat, 0) gt.finish() self.targets.append(gt.get_targets()[0])
def transform_dtrace(args): tree = default_tree(args) tree['ring_buffer'] = True args.no_left_overs = True gt = get_exporters()['gt'] with Callbacks(args, tree) as callbacks: if callbacks.is_empty(): return callbacks.get_result() dtrace = DTrace(args, gt, callbacks) with Progress(os.path.getsize(args.input), 50, "Parsing: " + os.path.basename(args.input)) as progress: count = 0 with codecs.open(args.input, 'r', 'utf-8', errors='ignore') as file: reading_stack = None stack = [] for line in file: line = line.strip() if not line: if reading_stack: dtrace.handle_stack(*(reading_stack + [stack])) reading_stack = None stack = [] continue if reading_stack: stack.append(line) continue parts = line.split('\t') if parts[1] == 'stack': reading_stack = [ int(parts[0], 16), parts[2], parts[3].rstrip(':') ] continue dtrace.handle_record(int(parts[0], 16), parts[1], parts[2:]) if not count % 1000: progress.tick(file.tell()) count += 1 dtrace.finalize() return callbacks.get_result()
def transform_dtrace(args): tree = default_tree(args) tree['ring_buffer'] = True args.no_left_overs = True gt = get_exporters()['gt'] with Callbacks(args, tree) as callbacks: if callbacks.is_empty(): return callbacks.get_result() dtrace = DTrace(args, gt, callbacks) with Progress(os.path.getsize(args.input), 50, "Parsing: " + os.path.basename(args.input)) as progress: count = 0 with open(args.input) as file: for line in file: line = line.strip() if not line: continue parts = line.split('\t') dtrace.handle_record(int(parts[0], 16), parts[1], parts[2:]) if not count % 1000: progress.tick(file.tell()) count += 1 dtrace.finalize() return callbacks.get_result() + dtrace.get_result()