4 ## Copyright (c) 2010-2017 Intel Corporation
6 ## Licensed under the Apache License, Version 2.0 (the "License");
7 ## you may not use this file except in compliance with the License.
8 ## You may obtain a copy of the License at
10 ## http://www.apache.org/licenses/LICENSE-2.0
12 ## Unless required by applicable law or agreed to in writing, software
13 ## distributed under the License is distributed on an "AS IS" BASIS,
14 ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 ## See the License for the specific language governing permissions and
16 ## limitations under the License.
23 print "usage: " + progName + " config [up|down]"
24 print " The script reads a lua configuration "
25 print " and outputs a histogram wit 21 buckets."
26 print " The first 20 buckets contain 70th percentile."
27 print " The last bucket contains the remaining items."
30 if (len(sys.argv) != 3):
33 if (sys.argv[2] == "down"):
35 elif (sys.argv[2] == "up"):
41 for line in open(sys.argv[1]).readlines():
44 if line.find(match) != -1:
45 v = line.split(" = ")[1].strip(",")
46 values.append(Decimal(v));
48 values = sorted(values)
50 treshold = values[int(len(values)*0.7)]
58 buckets[int(v * 20 / treshold)] += 1
60 stepSize = treshold / 20;
62 print "# bucket range, count"
63 for i in range(len(buckets) - 1):
64 beg = str(int(i * stepSize))
65 end = str(int((i + 1) * stepSize - 1))
66 print beg + "-" + end + "," + str(buckets[i])
69 print beg + "+," + str(buckets[i])