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 3 # found in the LICENSE file. 4 5 # 6 # Common code for parsing --trace-gc-nvp output. 7 # 8 9 10 from __future__ import with_statement 11 import re 12 13 def split_nvp(s): 14 t = {} 15 for (name, value) in re.findall(r"([._\w]+)=([-\w]+(?:\.[0-9]+)?)", s): 16 try: 17 t[name] = float(value) 18 except ValueError: 19 t[name] = value 20 21 return t 22 23 24 def parse_gc_trace(input): 25 trace = [] 26 with open(input) as f: 27 for line in f: 28 info = split_nvp(line) 29 if info and 'pause' in info and info['pause'] > 0: 30 info['i'] = len(trace) 31 trace.append(info) 32 return trace 33