OLD | NEW |
1 #! /usr/bin/python | 1 #! /usr/bin/python |
2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Convert trace output for Chrome. | 6 """Convert trace output for Chrome. |
7 | 7 |
8 Takes a loading trace from 'analyze.py log_requests' and outputs a zip'd json | 8 Takes a loading trace from 'analyze.py log_requests' and outputs a json file |
9 that can be loaded by chrome's about:tracing.. | 9 that can be loaded by chrome's about:tracing.. |
10 """ | 10 """ |
11 | 11 |
12 import argparse | 12 import argparse |
13 import gzip | |
14 import json | 13 import json |
15 | 14 |
16 if __name__ == '__main__': | 15 if __name__ == '__main__': |
17 parser = argparse.ArgumentParser() | 16 parser = argparse.ArgumentParser() |
18 parser.add_argument('input') | 17 parser.add_argument('input') |
19 parser.add_argument('output') | 18 parser.add_argument('output') |
20 args = parser.parse_args() | 19 args = parser.parse_args() |
21 with gzip.GzipFile(args.output, 'w') as output_f, file(args.input) as input_f: | 20 with file(args.output, 'w') as output_f, file(args.input) as input_f: |
22 events = json.load(input_f)['tracing_track']['events'] | 21 events = json.load(input_f)['tracing_track']['events'] |
23 json.dump({'traceEvents': events, 'metadata': {}}, output_f) | 22 json.dump({'traceEvents': events, 'metadata': {}}, output_f) |
OLD | NEW |