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

Side by Side Diff: tools/android/memdump/memreport.py

Issue 15861023: Add tools/android/memdump/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Polish Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/usr/bin/python
2
3 import re
4 import sys
5
6 from sets import Set
7
8 ENTRIES = [
bulach 2013/05/30 11:47:07 nits: prefix this and all other functions with _ s
Philippe 2013/05/30 13:48:43 Done.
9 ('Total', '.* r... .*'),
10 ('Read-only', '.* r--. .*'),
11 ('Read-write', '.* rw-. .*'),
12 ('Executable', '.* ..x. .*'),
13 ('File read-write', '.* rw.. .* /.*'),
14 ('Anonymous read-write', '.* rw.. .* .*other=[0-9]+ ($|.*chromium:.*)'),
15 ('File executable', '.* ..x. .* /.*'),
16 ('Anonymous executable (JIT\'ed code)', '.* ..x. .* shared_other=[0-9]+ $'),
17 ('chromium mmap', '.* r... .*chromium:.*'),
18 ('chromium TransferBuffer', '.* r... .*chromium:.*CreateTransferBuffer.*'),
19 ('Galaxy Nexus GL driver', '.* r... .*pvrsrvkm.*'),
20 ('Dalvik', '.* rw.. .* /.*dalvik.*'),
21 ('Dalvik heap', '.* rw.. .* /.*dalvik-heap.*'),
22 ('Native heap (jemalloc)', '.* r... .* /.*jemalloc.*'),
23 ('System heap', '.* r... .* \\[heap\\]'),
24 ('Ashmem', '.* rw.. .* /dev/ashmem .*'),
25 ('libchromeview.so total', '.* r... .* /.*libchromeview.so'),
26 ('libchromeview.so read-only', '.* r--. .* /.*libchromeview.so'),
27 ('libchromeview.so read-write', '.* rw-. .* /.*libchromeview.so'),
28 ('libchromeview.so executable', '.* r.x. .* /.*libchromeview.so'),
29 ]
30
31 def CollectMemoryStats(memdump, region_filters):
32 processes = []
33 mem_usage_for_regions = None
34 regexps = {}
35 for region_filter in region_filters:
36 regexps[region_filter] = re.compile(region_filter)
37 for line in memdump:
38 if 'PID=' in line:
39 mem_usage_for_regions = {}
40 processes.append(mem_usage_for_regions)
41 continue
42 current_regions = Set([])
43 for region_filter in region_filters:
44 if regexps[region_filter].match(line):
45 current_regions.add(region_filter)
46 if not region_filter in mem_usage_for_regions:
47 mem_usage_for_regions[region_filter] = {
48 'private': 0,
49 'shared_app': 0,
50 'shared_other': 0,
51 }
52 for current_region in current_regions:
53 mem_usage = mem_usage_for_regions[current_region]
54 for key in mem_usage:
55 for token in line.split(' '):
56 if key in token:
57 mem_usage[key] += int(token.split('=')[1])
58 break
59 return processes
60
61 def ConvertMemoryField(field):
62 return str(field / (1024.0 * 1024))
63
64 def DumpCSV(processes_stats):
65 total_map = {}
66 i = 0
67 for process in processes_stats:
68 i += 1
69 print ',Process ' + str(i) + ',private,shared_app,shared_other,'
70 for (k, v) in ENTRIES:
71 if not v in process:
72 print ',' + k + ',0,0,0,'
73 continue
74 if not v in total_map:
75 total_map[v] = 0
76 total_map[v] += process[v]['private'] + (
77 process[v]['shared_app'] / len(processes_stats))
78 print ',' + k + ',' + ConvertMemoryField(process[v]['private']) + ',' + (
79 ConvertMemoryField(process[v]['shared_app']) + ',' + (
80 ConvertMemoryField(process[v]['shared_other'])) + ',')
81 print ''
82
83 for (k, v) in ENTRIES:
84 if not v in total_map:
85 print ',' + k + ',0,0'
86 continue
87 print ',' + k + ',' + ConvertMemoryField(total_map[v]) + ','
88 print ''
89
90 def main(argv):
91 DumpCSV(CollectMemoryStats(sys.stdin, [value for (key, value) in ENTRIES]))
92
93 if __name__ == '__main__':
94 main(sys.argv)
OLDNEW
« tools/android/memdump/memdump.cc ('K') | « tools/android/memdump/memdump.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698