Guest
Public paste!

livibetter

By: a guest | Nov 4th, 2009 | Syntax: None | Size: 1.58 KB | Hits: 103 | Expires: Never
Copy text to clipboard
  1. #!/usr/bin/env python
  2.  
  3. from matplotlib import pyplot
  4. from matplotlib.ticker import IndexLocator
  5. from numpy import *
  6.  
  7. results = [
  8.     ('2.6.31-gentoo-r4', [36.232, 23.511, 21.74, 21.7, 21.954]),
  9.     ('2.6.31-gentoo-r4-bfs', [35.235, 20.168, 20.885, 21.308, 21.433]),
  10.     ('2.6.32-rc5', [35.746, 20.327, 20.902, 21.397, 21.741]),
  11.     ]
  12.  
  13. left, width = 0.1, 0.8
  14. rect1 = [left, 0.3, width, 0.6]
  15. rect2 = [left, 0.1, width, 0.2]
  16.  
  17. fig = pyplot.figure()
  18. ax1 = fig.add_axes(rect1)
  19. ax2 = fig.add_axes(rect2, sharex=ax1)
  20.  
  21. ax1.hold(True)
  22. x = range(1, len(results[0][1]) + 1)
  23. for result in results:
  24.   ax1.plot(x, result[1], label=result[0])
  25. ax1.legend(loc=0)
  26. ax1.set_xlim([0, 6])
  27. ax1.xaxis.set_major_locator(IndexLocator(1, 0))
  28. ax1.grid(which='major')
  29. ax1.set_xlabel('', visible=False)
  30. ax1.set_ylabel('Compilation time (second)')
  31.  
  32. for lbl in ax1.get_xticklabels():
  33.   lbl.set_visible(False)
  34. ax1.get_yticklabels()[0].set_visible(False)
  35.  
  36. base = array(results[0][1])
  37. comp = array(results[1][1])
  38. perf = -1 * (comp - base) / base * 100
  39. ymin = []
  40. ymax = []
  41. for r in perf:
  42.   if r < 0:
  43.     ymin.append(r)
  44.     ymax.append(0)
  45.   else:
  46.     ymin.append(0)
  47.     ymax.append(r)
  48.  
  49. ax2.vlines(x, ymin, ymax, linewidth='10', color='blue')
  50. ax2.xaxis.set_major_locator(IndexLocator(1, 0))
  51. ax2.set_xlim([0, 6])
  52. ax2.grid(which='major')
  53. ax2.set_ylabel('Improvement (%)')
  54. ax2.set_xlabel('Jobs')
  55.  
  56. ax2.get_yticklabels()[-1].set_visible(False)
  57.  
  58. for i in range(len(results[0][1])):
  59.   print '%3d %9f %9f %9f %6.2f%%' % (i + 1, results[0][1][i], results[1][1][i], results[2][1][i], perf[i])
  60.  
  61. pyplot.show()