Commit c136032c authored by rmcilroy's avatar rmcilroy Committed by Commit bot

[tools] Add gc-nvp-to-csv.py script.

Adds a script for converting gc nvp output into csv files. Factors out common
code in gc-nvp-trace-processor.py to gc_nvp_common.py to be shared by both
scripts. Fixes a couple of issues in nvp parsing code.

Review URL: https://codereview.chromium.org/1175113008

Cr-Commit-Position: refs/heads/master@{#29141}
parent 29c575bc
#!/usr/bin/env python
#
# Copyright 2015 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# This is an utility for generating csv files based on GC traces produced by
# V8 when run with flags --trace-gc --trace-gc-nvp.
#
# Usage: gc-nvp-to-csv.py <GC-trace-filename>
#
import sys
import gc_nvp_common
def process_trace(filename):
trace = gc_nvp_common.parse_gc_trace(filename)
if len(trace):
keys = trace[0].keys()
print ', '.join(keys)
for entry in trace:
print ', '.join(map(lambda key: str(entry[key]), keys))
if len(sys.argv) != 2:
print "Usage: %s <GC-trace-filename>" % sys.argv[0]
sys.exit(1)
process_trace(sys.argv[1])
......@@ -38,44 +38,14 @@
from __future__ import with_statement
import sys, types, re, subprocess, math
import sys, types, subprocess, math
import gc_nvp_common
def flatten(l):
flat = []
for i in l: flat.extend(i)
return flat
def split_nvp(s):
t = {}
for (name, value) in re.findall(r"(\w+)=([-\w]+)", s):
try:
t[name] = int(value)
except ValueError:
t[name] = value
return t
def parse_gc_trace(input):
trace = []
with open(input) as f:
for line in f:
info = split_nvp(line)
if info and 'pause' in info and info['pause'] > 0:
info['i'] = len(trace)
trace.append(info)
return trace
def extract_field_names(script):
fields = { 'data': true, 'in': true }
for m in re.finditer(r"$(\w+)", script):
field_name = m.group(1)
if field_name not in fields:
fields[field] = field_count
field_count = field_count + 1
return fields
def gnuplot(script):
gnuplot = subprocess.Popen(["gnuplot"], stdin=subprocess.PIPE)
gnuplot.stdin.write(script)
......@@ -228,7 +198,7 @@ def scavenge_scope(r):
def real_mutator(r):
return r['mutator'] - r['stepstook']
return r['mutator'] - r['steps_took']
plots = [
[
......@@ -240,7 +210,7 @@ plots = [
Item('Sweep', 'sweep', lc = 'blue'),
Item('External', 'external', lc = '#489D43'),
Item('Other', other_scope, lc = 'grey'),
Item('IGC Steps', 'stepstook', lc = '#FF6347'))
Item('IGC Steps', 'steps_took', lc = '#FF6347'))
],
[
Set('style fill solid 0.5 noborder'),
......@@ -304,7 +274,7 @@ def count_nonzero(trace, field):
def process_trace(filename):
trace = parse_gc_trace(filename)
trace = gc_nvp_common.parse_gc_trace(filename)
marksweeps = filter(lambda r: r['gc'] == 'ms', trace)
scavenges = filter(lambda r: r['gc'] == 's', trace)
......
# Copyright 2015 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# Common code for parsing --trace-gc-nvp output.
#
from __future__ import with_statement
import re
def split_nvp(s):
t = {}
for (name, value) in re.findall(r"(\w+)=([-\w]+)", s):
try:
t[name] = float(value)
except ValueError:
t[name] = value
return t
def parse_gc_trace(input):
trace = []
with open(input) as f:
for line in f:
info = split_nvp(line)
if info and 'pause' in info and info['pause'] > 0:
info['i'] = len(trace)
trace.append(info)
return trace
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment