Reviewers: Christian Plesner Hansen, Description: 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. Please review this at http://codereview.chromium.org/385001 SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/ Affected files: M tools/process-heap-prof.py Index: tools/process-heap-prof.py =================================================================== --- tools/process-heap-prof.py (revision 3252) +++ tools/process-heap-prof.py (working copy) @@ -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,43 @@ 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 + + +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) --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---
