Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Unified Diff: tools/process-heap-prof.py

Issue 385001: Report both size and count from the heap profile processor... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,48 @@
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())
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698