From: José Fonseca Date: Wed, 29 Jul 2009 11:40:11 +0000 (+0100) Subject: Dump call durations. X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=9604853c40e66b2aa3ad9c69eb16f9598d1d86e3;p=apitrace Dump call durations. --- diff --git a/xml2txt.py b/xml2txt.py index 21f0fc4..809596a 100755 --- a/xml2txt.py +++ b/xml2txt.py @@ -256,12 +256,15 @@ class TraceParser(XmlParser): name = attrs['name'] args = [] ret = None + duration = None while self.token.type == ELEMENT_START: if self.token.name_or_data == 'arg': arg = self.parse_arg() args.append(arg) elif self.token.name_or_data == 'ret': ret = self.parse_ret() + elif self.token.name_or_data == 'duration': + duration = self.parse_duration() elif self.token.name_or_data == 'call': # ignore nested function calls self.parse_call() @@ -269,7 +272,12 @@ class TraceParser(XmlParser): raise TokenMismatch(" or ", self.token) self.element_end('call') - call = self.formatter.function(name) + call = '' + + if duration is not None: + call += '%8u ' % (duration) + + call += self.formatter.function(name) call += '(' + ', '.join([self.formatter.variable(name) + ' = ' + value for name, value in args]) + ')' if ret is not None: call += ' = ' + ret @@ -296,6 +304,12 @@ class TraceParser(XmlParser): return value + def parse_duration(self): + attrs = self.element_start('duration') + value = int(self.character_data()) + self.element_end('duration') + return value + def parse_value(self): if self.token.type == CHARACTER_DATA: return self.formatter.literal(self.character_data())