blob: e739b4702ce5052320b751f1174f71ebd35e6c98 [file] [log] [blame]
Florian Mayerbb54f5e2018-10-22 12:13:03 +01001#!/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 Mayerbb54f5e2018-10-22 12:13:03 +010017import sys
18
Florian Mayerbb54f5e2018-10-22 12:13:03 +010019import scipy as sp
20import seaborn as sns
21
22from collections import defaultdict
23from matplotlib import pyplot as plt
24
Primiano Tucci834fdc72019-10-04 11:33:44 +010025
Florian Mayerbb54f5e2018-10-22 12:13:03 +010026def 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 Tucci834fdc72019-10-04 11:33:44 +010046 flat_distributions = {
Octavian Tuchila5f3b52a2021-03-23 17:48:34 +000047 key: list(value.values()) for key, value in distributions.items()
Primiano Tucci834fdc72019-10-04 11:33:44 +010048 }
Florian Mayerbb54f5e2018-10-22 12:13:03 +010049
Octavian Tuchila5f3b52a2021-03-23 17:48:34 +000050 for key, value in flat_distributions.items():
51 print(key, "ground truth %d " % ground_truth[key], sp.stats.describe(value))
Florian Mayerbb54f5e2018-10-22 12:13:03 +010052 sns.distplot(value)
53 plt.show()
54
55
56if __name__ == '__main__':
57 main(sys.argv)