Chromium Code Reviews| OLD | NEW |
|---|---|
| (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() | |
| OLD | NEW |