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 def GetResultPfns(log_filename): |
| 17 for line in open(log_filename): |
| 18 parts = line.strip('\n')[:-1].split(' '); |
| 19 yield [int(part, 16) for part in parts] |
| 20 |
| 21 |
| 22 def Main(): |
| 23 cont_count = {} |
| 24 for pfns in GetResultPfns('physmem_alloc_results'): |
| 25 i1 = 0 |
| 26 i2 = 0 |
| 27 while i2 < len(pfns): |
| 28 while i2 + 1 < len(pfns) and pfns[i2+1] - pfns[i2] == 1: |
| 29 i2 += 1 |
| 30 size = i2 - i1 + 1 |
| 31 cont_count.setdefault(size, 0) |
| 32 cont_count[size] += 1 |
| 33 i2 += 1 |
| 34 i1 = i2 |
| 35 |
| 36 total_pages = 0 |
| 37 for size, count in cont_count.iteritems(): |
| 38 total_pages += size * count |
| 39 |
| 40 sorted_by_size = sorted(cont_count.iteritems()) |
| 41 for size, count in sorted_by_size: |
| 42 size_total = size * count |
| 43 fraction = 1.0 * size_total / total_pages |
| 44 print '%10d %10d %10d %10.2f' % (size, count, size_total, fraction) |
| 45 |
| 46 if __name__ == '__main__': |
| 47 Main() |
OLD | NEW |