| OLD | NEW |
| 1 # Copyright 2015 the V8 project authors. All rights reserved. | 1 # Copyright 2015 the V8 project authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 # | 5 # |
| 6 # Common code for parsing --trace-gc-nvp output. | 6 # Common code for parsing --trace-gc-nvp output. |
| 7 # | 7 # |
| 8 | 8 |
| 9 | 9 |
| 10 from __future__ import with_statement | 10 from __future__ import with_statement |
| 11 import re | 11 import re |
| 12 | 12 |
| 13 def split_nvp(s): | 13 def split_nvp(s): |
| 14 t = {} | 14 t = {} |
| 15 for (name, value) in re.findall(r"(\w+)=([-\w]+(?:\.[0-9]+)?)", s): | 15 for (name, value) in re.findall(r"([._\w]+)=([-\w]+(?:\.[0-9]+)?)", s): |
| 16 try: | 16 try: |
| 17 t[name] = float(value) | 17 t[name] = float(value) |
| 18 except ValueError: | 18 except ValueError: |
| 19 t[name] = value | 19 t[name] = value |
| 20 | 20 |
| 21 return t | 21 return t |
| 22 | 22 |
| 23 | 23 |
| 24 def parse_gc_trace(input): | 24 def parse_gc_trace(input): |
| 25 trace = [] | 25 trace = [] |
| 26 with open(input) as f: | 26 with open(input) as f: |
| 27 for line in f: | 27 for line in f: |
| 28 info = split_nvp(line) | 28 info = split_nvp(line) |
| 29 if info and 'pause' in info and info['pause'] > 0: | 29 if info and 'pause' in info and info['pause'] > 0: |
| 30 info['i'] = len(trace) | 30 info['i'] = len(trace) |
| 31 trace.append(info) | 31 trace.append(info) |
| 32 return trace | 32 return trace |
| OLD | NEW |