1#!/usr/bin/env python 2# 3# Copyright 2015 the V8 project authors. All rights reserved. 4# Use of this source code is governed by a BSD-style license that can be 5# found in the LICENSE file. 6 7# 8# This is an utility for generating csv files based on GC traces produced by 9# V8 when run with flags --trace-gc --trace-gc-nvp. 10# 11# Usage: gc-nvp-to-csv.py <GC-trace-filename> 12# 13 14 15# for py2/py3 compatibility 16from __future__ import print_function 17 18import sys 19import gc_nvp_common 20 21 22def process_trace(filename): 23 trace = gc_nvp_common.parse_gc_trace(filename) 24 if len(trace): 25 keys = trace[0].keys() 26 print(', '.join(keys)) 27 for entry in trace: 28 print(', '.join(map(lambda key: str(entry[key]), keys))) 29 30 31if len(sys.argv) != 2: 32 print("Usage: %s <GC-trace-filename>" % sys.argv[0]) 33 sys.exit(1) 34 35process_trace(sys.argv[1]) 36