diff --git a/ChangeLog b/ChangeLog index 530e2714..966cbf18 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24,6 +24,7 @@ - add --strip option to jpegsave - added vips_gaussblur() convenience function - added --vips-profile, records and dumps thread timing info +- added vipsprofile.py, visualises --vips-profile output 15/11/13 started 7.36.4 - improve compat with im_init_world() diff --git a/TODO b/TODO index 5fb6ce4a..ae3d2f13 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,8 @@ +- seen some leaks from + + vips dzsave --layout google wtc.jpg x + + investigate - parse and graph vips-profile data diff --git a/tools/vipsprofile.py b/tools/vipsprofile.py new file mode 100755 index 00000000..dba0b05e --- /dev/null +++ b/tools/vipsprofile.py @@ -0,0 +1,68 @@ +#!/usr/bin/python + +import re + +class ReadFile: + def __init__(self, filename): + self.filename = filename + + def __enter__(self): + self.f = open(self.filename, 'r') + self.source = iter(self.f.readline, '') + self.lineno = 0 + self.getnext(); + return self + + def __exit__(self, type, value, traceback): + self.f.close() + return isinstance(value, StopIteration) + + def __nonzero__(self): + return self.line != "" + + def getnext(self): + self.lineno += 1 + self.line = self.source.next() + +def read_times(rf): + times = [] + + while True: + match = re.match('[0-9]+ ', rf.line) + if not match: + break + times.append([int(x) for x in re.split(' ', rf.line.rstrip())]) + rf.getnext() + + return times[::-1] + +with ReadFile('vips-profile.txt') as rf: + while rf: + match = re.match('thread: (.*) \(0x([0-9a-f]+)\)', rf.line) + if not match: + print 'parse error line %d, expected "thread"' % rf.lineno + thread_name = match.group(1) + thread_addr = match.group(2) + rf.getnext() + + while True: + match = re.match('gate: (.*)', rf.line) + if not match: + break + gate_name = match.group(1) + rf.getnext() + + match = re.match('start:', rf.line) + if not match: + continue + rf.getnext() + + times = read_times(rf) + + match = re.match('stop:', rf.line) + if not match: + continue + rf.getnext() + + times = read_times(rf) +