X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=scripts%2Fretracediff.py;h=ee5730ab4988178dba51e6f9a6feb1a6dac647e5;hb=d8ea58f1e7d2e0dd9cabd085eef6f8b227e88652;hp=34959753fc0acf9b137e07394a6e60e621028e9d;hpb=4d73f8586100da4bbf5dcfad94828ae0b227ec05;p=apitrace diff --git a/scripts/retracediff.py b/scripts/retracediff.py index 3495975..ee5730a 100755 --- a/scripts/retracediff.py +++ b/scripts/retracediff.py @@ -80,16 +80,16 @@ class Setup: p.wait() return state.get('parameters', {}) - def diff_state(self, ref_call_no, src_call_no): + def diff_state(self, ref_call_no, src_call_no, stream): '''Compare the state between two calls.''' ref_state = self.dump_state(ref_call_no) src_state = self.dump_state(src_call_no) - sys.stdout.flush() - differ = jsondiff.Differ(sys.stdout) + stream.flush() + differ = jsondiff.Differ(stream) differ.visit(ref_state, src_state) - sys.stdout.write('\n') + stream.write('\n') def read_pnm(stream): @@ -159,6 +159,10 @@ def main(): '-S', '--snapshot-frequency', metavar='CALLSET', type="string", dest="snapshot_frequency", default='draw', help="calls to compare [default: %default]") + optparser.add_option( + '-o', '--output', metavar='FILE', + type="string", dest="output", + help="output file [default: stdout]") (options, args) = optparser.parse_args(sys.argv[1:]) ref_env = parse_env(optparser, options.ref_env) @@ -169,7 +173,12 @@ def main(): ref_setup = Setup(args, ref_env) src_setup = Setup(args, src_env) - highligher = Highlighter(sys.stdout) + if options.output: + output = open(options.output, 'wt') + else: + output = sys.stdout + + highligher = Highlighter(output) highligher.write('call\tprecision\n') @@ -217,7 +226,7 @@ def main(): src_image.save(prefix + '.src.png') comparer.write_diff(prefix + '.diff.png') if last_bad < last_good: - src_setup.diff_state(last_good, call_no) + src_setup.diff_state(last_good, call_no, output) last_bad = call_no else: last_good = call_no