Florian Mayer | bb54f5e | 2018-10-22 12:13:03 +0100 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | # Copyright (C) 2018 The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
Florian Mayer | bb54f5e | 2018-10-22 12:13:03 +0100 | [diff] [blame] | 17 | import sys |
| 18 | |
Florian Mayer | bb54f5e | 2018-10-22 12:13:03 +0100 | [diff] [blame] | 19 | import scipy as sp |
| 20 | import seaborn as sns |
| 21 | |
| 22 | from collections import defaultdict |
| 23 | from matplotlib import pyplot as plt |
| 24 | |
Primiano Tucci | 834fdc7 | 2019-10-04 11:33:44 +0100 | [diff] [blame] | 25 | |
Florian Mayer | bb54f5e | 2018-10-22 12:13:03 +0100 | [diff] [blame] | 26 | def main(argv): |
| 27 | sns.set() |
| 28 | |
| 29 | # Map from key to map from iteration id to bytes allocated. |
| 30 | distributions = defaultdict(lambda: defaultdict(int)) |
| 31 | ground_truth = {} |
| 32 | for line in sys.stdin: |
| 33 | stripped = line.strip() |
| 34 | # Skip empty lines |
| 35 | if not stripped: |
| 36 | continue |
| 37 | itr, code_location, size = stripped.split(" ") |
| 38 | if itr == 'g': |
| 39 | assert code_location not in ground_truth |
| 40 | ground_truth[code_location] = int(size) |
| 41 | else: |
| 42 | assert int(itr) not in distributions[code_location] |
| 43 | distributions[code_location][int(itr)] += int(size) |
| 44 | |
| 45 | # Map from key to list of bytes allocated, one for each iteration. |
Primiano Tucci | 834fdc7 | 2019-10-04 11:33:44 +0100 | [diff] [blame] | 46 | flat_distributions = { |
Octavian Tuchila | 5f3b52a | 2021-03-23 17:48:34 +0000 | [diff] [blame] | 47 | key: list(value.values()) for key, value in distributions.items() |
Primiano Tucci | 834fdc7 | 2019-10-04 11:33:44 +0100 | [diff] [blame] | 48 | } |
Florian Mayer | bb54f5e | 2018-10-22 12:13:03 +0100 | [diff] [blame] | 49 | |
Octavian Tuchila | 5f3b52a | 2021-03-23 17:48:34 +0000 | [diff] [blame] | 50 | for key, value in flat_distributions.items(): |
| 51 | print(key, "ground truth %d " % ground_truth[key], sp.stats.describe(value)) |
Florian Mayer | bb54f5e | 2018-10-22 12:13:03 +0100 | [diff] [blame] | 52 | sns.distplot(value) |
| 53 | plt.show() |
| 54 | |
| 55 | |
| 56 | if __name__ == '__main__': |
| 57 | main(sys.argv) |