Guest
Public paste!

livibetter

By: a guest | Nov 4th, 2009 | Syntax: None | Size: 3.54 KB | Hits: 116 | 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', [0.15673866271972656, 0.22011380195617675, 0.31147456169128418, 0.31806101799011233, 0.45194501876831056, 0.49375133514404296, 0.61773824691772461, 0.63911833763122561, 0.75951099395751953, 0.78272194862365718, 0.88353796005249019, 0.94253153800964351, 1.0565287590026855, 1.0960891723632813, 1.2079774379730224, 1.2763566017150878, 1.3607078075408936, 1.4153385639190674, 1.5076858043670653, 1.6175025463104249, 1.6524959564208985, 1.7378323554992676, 1.7971437931060792, 1.8734035968780518, 1.9591879844665527, 2.0440726280212402, 2.094032573699951, 2.1864066123962402, 2.2562743663787841, 2.3418245792388914, 2.4131356239318849, 2.5000920772552488]),
  9.     ('2.6.31-gentoo-r4-bfs', [0.15105123519897462, 0.15202860832214354, 0.23054533004760741, 0.31636881828308105, 0.37918915748596194, 0.46293921470642091, 0.53474774360656741, 0.61435899734497068, 0.68547730445861821, 0.76638255119323728, 0.83417096138000491, 0.91335644721984866, 0.99857978820800786, 1.062566375732422, 1.1367023468017579, 1.2150913715362548, 1.2890355587005615, 1.3727387905120849, 1.4421934127807616, 1.5104918003082275, 1.592773151397705, 1.6809540271759034, 1.7389869689941406, 1.8142241477966308, 1.8861724376678466, 1.9673441886901855, 2.0324893951416017, 2.1128292083740234, 2.1875843524932863, 2.2638030529022215, 2.3384195804595946, 2.4296010017395018]),
  10.     ('2.6.32-rc5', [0.15692081451416015, 0.15577034950256347, 0.23881216049194337, 0.30775957107543944, 0.39050402641296389, 0.46690564155578612, 0.54277920722961426, 0.61949896812438965, 0.69837198257446287, 0.77543320655822756, 0.85235204696655276, 0.93067021369934078, 1.0140983581542968, 1.0921456336975097, 1.1726108551025392, 1.2533286571502686, 1.3232304096221923, 1.4089258670806886, 1.4863292217254638, 1.5622700214385987, 1.6449746131896972, 1.7351542472839356, 1.8334334373474122, 1.880321741104126, 1.9584332466125489, 2.0412515163421632, 2.1100759983062742, 2.1974469661712646, 2.2678318023681641, 2.3443553924560545, 2.4461697578430175, 2.5226269721984864]),
  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.semilogy(x, result[1], label=result[0])
  25. ax1.legend(loc=0)
  26. ax1.xaxis.set_minor_locator(IndexLocator(1, 0))
  27. ax1.grid(which='major', linestyle='-')
  28. ax1.grid(which='minor')
  29. ax1.set_xlabel('', visible=False)
  30. ax1.set_ylabel('Elapsed time (second, log)')
  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_minor_locator(IndexLocator(1, 0))
  51. ax2.grid(which='major', linestyle='-')
  52. ax2.grid(which='minor')
  53. ax2.set_ylabel('Improvement (%)')
  54. ax2.set_xlabel('Concurrent processes')
  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(%9f) %9f(%9f) %6.2f%%' % (i + 1,
  60.       results[0][1][i], results[0][1][i]/(i+1),
  61.       results[1][1][i], results[1][1][i]/(i+1),
  62.       results[2][1][i], results[2][1][i]/(i+1),
  63.       perf[i])
  64. pyplot.show()