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 17import sys 18 19import scipy as sp 20import seaborn as sns 21 22from collections import defaultdict 23from matplotlib import pyplot as plt 24 25 26def 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. 46 flat_distributions = { 47 key: list(value.values()) for key, value in distributions.items() 48 } 49 50 for key, value in flat_distributions.items(): 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) 58