blob: a33ffb36dfad18afd7e9cbb894bacff733f7b7e4 [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
17import os
18import sys
19
20import numpy as np
21import scipy as sp
22import seaborn as sns
23
24from collections import defaultdict
25from matplotlib import pyplot as plt
26
27def main(argv):
28 sns.set()
29
30 # Map from key to map from iteration id to bytes allocated.
31 distributions = defaultdict(lambda: defaultdict(int))
32 ground_truth = {}
33 for line in sys.stdin:
34 stripped = line.strip()
35 # Skip empty lines
36 if not stripped:
37 continue
38 itr, code_location, size = stripped.split(" ")
39 if itr == 'g':
40 assert code_location not in ground_truth
41 ground_truth[code_location] = int(size)
42 else:
43 assert int(itr) not in distributions[code_location]
44 distributions[code_location][int(itr)] += int(size)
45
46 # Map from key to list of bytes allocated, one for each iteration.
47 flat_distributions = {key: value.values() for key, value
48 in distributions.iteritems()}
49
50 for key, value in flat_distributions.iteritems():
51 print key, "ground truth %d " % ground_truth[key], sp.stats.describe(value)
52 sns.distplot(value)
53 plt.show()
54
55
56if __name__ == '__main__':
57 main(sys.argv)