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

Side by Side Diff: physmem_alloc_analysis/physmem_alloc_analyzer.py

Issue 1217243006: Analyze contiguous physical memory chunks that mmap system call gives (Closed) Base URL: https://github.com/acutebridge/rowhammer-test.git@phymem_alloc
Patch Set: Addressed code review comments Created 5 years, 5 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 | « physmem_alloc_analysis/make.sh ('k') | physmem_alloc_analysis/physmem_alloc_profiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2015, Google, Inc.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15
16 import operator
Mark Seaborn 2015/07/06 17:32:33 Not used now
ruiq 2015/07/07 01:12:50 Done.
17
18
19 def GetResultPfns(log_filename):
20 for line in open(log_filename):
21 parts = line.strip('\n')[:-1].split(' ');
22 yield [int(part, 16) for part in parts]
23
24
25 def Main():
26 cont_count = {}
27 for pfns in GetResultPfns('physmem_alloc_results'):
28 i1 = 0
29 i2 = 0
30 while i2 < len(pfns):
31 while i2 + 1 < len(pfns) and pfns[i2+1] - pfns[i2] == 1:
32 i2 += 1
33 size = i2 - i1 + 1
34 cont_count.setdefault(size, 0)
35 cont_count[size] += 1
36 i2 += 1
37 i1 = i2
38
39 total_pages = 0
40 for size, count in cont_count.iteritems():
41 total_pages += size * count
42
43 sorted_by_size = sorted(cont_count.items())
Mark Seaborn 2015/07/06 17:32:33 Nit: iteritems() should work here too (for consist
ruiq 2015/07/07 01:12:50 Done.
44 for size, count in sorted_by_size:
45 size_total = size * count
46 fraction = 1.0 * size_total / total_pages
47 print '%10d %10d %10d %10.2f' % (size, count, size_total, fraction)
48
49 if __name__ == '__main__':
50 Main()
OLDNEW
« no previous file with comments | « physmem_alloc_analysis/make.sh ('k') | physmem_alloc_analysis/physmem_alloc_profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698