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

Side by Side Diff: tools/process-heap-prof.py

Issue 159504: Introduce first approximation of constructor heap profile for JS objects. (Closed)
Patch Set: Soeren's comments applied Created 11 years, 4 months 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 unified diff | Download patch
« no previous file with comments | « test/cctest/test-regexp.cc ('k') | tools/visual_studio/v8_base.vcproj » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2009 the V8 project authors. All rights reserved. 3 # Copyright 2009 the V8 project authors. All rights reserved.
4 # Redistribution and use in source and binary forms, with or without 4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are 5 # modification, are permitted provided that the following conditions are
6 # met: 6 # met:
7 # 7 #
8 # * Redistributions of source code must retain the above copyright 8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer. 9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above 10 # * Redistributions in binary form must reproduce the above
(...skipping 17 matching lines...) Expand all
28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 29
30 # This is an utility for converting V8 heap logs into .hp files that can 30 # This is an utility for converting V8 heap logs into .hp files that can
31 # be further processed using 'hp2ps' tool (bundled with GHC and Valgrind) 31 # be further processed using 'hp2ps' tool (bundled with GHC and Valgrind)
32 # to produce heap usage histograms. 32 # to produce heap usage histograms.
33 33
34 # Sample usage: 34 # Sample usage:
35 # $ ./shell --log-gc script.js 35 # $ ./shell --log-gc script.js
36 # $ tools/process-heap-prof.py v8.log | hp2ps -c > script-heap-graph.ps 36 # $ tools/process-heap-prof.py v8.log | hp2ps -c > script-heap-graph.ps
37 # ('-c' enables color, see hp2ps manual page for more options) 37 # ('-c' enables color, see hp2ps manual page for more options)
38 # or
39 # $ tools/process-heap-prof.py --js-cons-profile v8.log | hp2ps -c > script-heap -graph.ps
40 # to get JS constructor profile
41
38 42
39 import csv, sys, time 43 import csv, sys, time
40 44
41 def process_logfile(filename): 45 def process_logfile(filename, itemname):
42 first_call_time = None 46 first_call_time = None
43 sample_time = 0.0 47 sample_time = 0.0
44 sampling = False 48 sampling = False
45 try: 49 try:
46 logfile = open(filename, 'rb') 50 logfile = open(filename, 'rb')
47 try: 51 try:
48 logreader = csv.reader(logfile) 52 logreader = csv.reader(logfile)
49 53
50 print('JOB "v8"') 54 print('JOB "v8"')
51 print('DATE "%s"' % time.asctime(time.localtime())) 55 print('DATE "%s"' % time.asctime(time.localtime()))
52 print('SAMPLE_UNIT "seconds"') 56 print('SAMPLE_UNIT "seconds"')
53 print('VALUE_UNIT "bytes"') 57 print('VALUE_UNIT "bytes"')
54 58
55 for row in logreader: 59 for row in logreader:
56 if row[0] == 'heap-sample-begin' and row[1] == 'Heap': 60 if row[0] == 'heap-sample-begin' and row[1] == 'Heap':
57 sample_time = float(row[3])/1000.0 61 sample_time = float(row[3])/1000.0
58 if first_call_time == None: 62 if first_call_time == None:
59 first_call_time = sample_time 63 first_call_time = sample_time
60 sample_time -= first_call_time 64 sample_time -= first_call_time
61 print('BEGIN_SAMPLE %.2f' % sample_time) 65 print('BEGIN_SAMPLE %.2f' % sample_time)
62 sampling = True 66 sampling = True
63 elif row[0] == 'heap-sample-end' and row[1] == 'Heap': 67 elif row[0] == 'heap-sample-end' and row[1] == 'Heap':
64 print('END_SAMPLE %.2f' % sample_time) 68 print('END_SAMPLE %.2f' % sample_time)
65 sampling = False 69 sampling = False
66 elif row[0] == 'heap-sample-item' and sampling: 70 elif row[0] == itemname and sampling:
67 print('%s %d' % (row[1], int(row[3]))) 71 print('%s %d' % (row[1], int(row[3])))
68 finally: 72 finally:
69 logfile.close() 73 logfile.close()
70 except: 74 except:
71 sys.exit('can\'t open %s' % filename) 75 sys.exit('can\'t open %s' % filename)
72 76
73 process_logfile(sys.argv[1]) 77 if sys.argv[1] == '--js-cons-profile':
78 process_logfile(sys.argv[2], 'heap-js-cons-item')
79 else:
80 process_logfile(sys.argv[1], 'heap-sample-item')
OLDNEW
« no previous file with comments | « test/cctest/test-regexp.cc ('k') | tools/visual_studio/v8_base.vcproj » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698