1 #!/usr/bin/env python 2 # 3 # Copyright (C) 2013 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 17 import os, sys 18 import get_csv_report as psr 19 import matplotlib.pyplot as plt 20 import matplotlib.mlab as mlab 21 import matplotlib.cbook as cbook 22 import matplotlib.ticker as ticker 23 """ 24 A simple script to render the data from the benchmark as a graph. 25 This uses MatPlotLib (http://matplotlib.org/) to plot which can be installed on linux with; 26 sudo apt-get install python-matplotlib 27 """ 28 29 colors = { 30 'maguro':'#FF0000', 31 'mako':'#00FF00', 32 'manta':'#0000FF', 33 'tilapia':'#00FFFF' 34 } 35 36 def main(argv): 37 if len(argv) != 2: 38 print "grapher.py cts_report_dir" 39 sys.exit(1) 40 41 (_, tests) = psr.parseReports(os.path.abspath(argv[1])) 42 43 # For each of the benchmarks 44 for benchmark in tests: 45 if benchmark.startswith('com.android.cts.opengl.primitive'): 46 results = tests[benchmark] 47 legend = [] 48 # Create a new figure 49 fig = plt.figure() 50 # Set the title of the graph 51 plt.title(benchmark[benchmark.index('#') + 1:]) 52 # For each result in the data set 53 for r in results: 54 score = r.get('result', 'no results') 55 x = [] 56 y = [] 57 if score == 'pass': 58 y = r['details']['Fps Values'] 59 x = range(1, len(y) + 1) 60 # Get the score, then trim it to 2 decimal places 61 score = r['summary']['Average Frames Per Second'] 62 score = score[0:score.index('.') + 3] 63 if score != 'no results': 64 # Create a plot 65 ax = fig.add_subplot(111) 66 name = r['device'] 67 lbl = name + ' (%s)'%score 68 clr = colors.get(name, "#%06X" % (hash(name) % 0xFFFFFF)) 69 # Plot the workload vs the values 70 ax.plot(x, y, 'o-', label=lbl, color=clr) 71 # Add a legend 72 ax.legend(loc='upper right').get_frame().set_fill(False) 73 (ymin, ymax) = plt.ylim() 74 if ymax < 90:# So that on screen tests are easier to compare 75 plt.ylim(0, 90) 76 plt.xlabel('Iteration') 77 plt.ylabel('FPS') 78 fig.autofmt_xdate() 79 # Show the plots 80 plt.show() 81 82 if __name__ == '__main__': 83 main(sys.argv) 84