Commit 0fbfa2f8 authored by sgjesse@chromium.org's avatar sgjesse@chromium.org

Report both size and count from the heap profile processor

Added two options for controlling this --size and --count. Default is --size to match the original behaviour.
Review URL: http://codereview.chromium.org/385001

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3256 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 091c7a23
......@@ -40,9 +40,14 @@
# to get JS constructor profile
import csv, sys, time
import csv, sys, time, optparse
def process_logfile(filename, itemname):
def ProcessLogFile(filename, options):
if options.js_cons_profile:
itemname = 'heap-js-cons-item'
else:
itemname = 'heap-sample-item'
first_call_time = None
sample_time = 0.0
sampling = False
......@@ -68,13 +73,48 @@ def process_logfile(filename, itemname):
print('END_SAMPLE %.2f' % sample_time)
sampling = False
elif row[0] == itemname and sampling:
print('%s %d' % (row[1], int(row[3])))
print(row[1]),
if options.count:
print('%d' % (int(row[2]))),
if options.size:
print('%d' % (int(row[3]))),
print
finally:
logfile.close()
except:
sys.exit('can\'t open %s' % filename)
if sys.argv[1] == '--js-cons-profile':
process_logfile(sys.argv[2], 'heap-js-cons-item')
else:
process_logfile(sys.argv[1], 'heap-sample-item')
def BuildOptions():
result = optparse.OptionParser()
result.add_option("--js_cons_profile", help="Constructor profile",
default=False, action="store_true")
result.add_option("--size", help="Report object size",
default=False, action="store_true")
result.add_option("--count", help="Report object count",
default=False, action="store_true")
return result
def ProcessOptions(options):
if not options.size and not options.count:
options.size = True
return True
def Main():
parser = BuildOptions()
(options, args) = parser.parse_args()
if not ProcessOptions(options):
parser.print_help()
sys.exit();
if not args:
print "Missing logfile"
sys.exit();
ProcessLogFile(args[0], options)
if __name__ == '__main__':
sys.exit(Main())
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