livibetter
By: a guest | Nov 4th, 2009 | Syntax:
None | Size: 1.58 KB | Hits: 103 | Expires: Never
#!/usr/bin/env python
from matplotlib import pyplot
from matplotlib.ticker import IndexLocator
from numpy import *
results = [
('2.6.31-gentoo-r4', [36.232, 23.511, 21.74, 21.7, 21.954]),
('2.6.31-gentoo-r4-bfs', [35.235, 20.168, 20.885, 21.308, 21.433]),
('2.6.32-rc5', [35.746, 20.327, 20.902, 21.397, 21.741]),
]
left, width = 0.1, 0.8
rect1 = [left, 0.3, width, 0.6]
rect2 = [left, 0.1, width, 0.2]
fig = pyplot.figure()
ax1 = fig.add_axes(rect1)
ax2 = fig.add_axes(rect2, sharex=ax1)
ax1.hold(True)
x = range(1, len(results[0][1]) + 1)
for result in results:
ax1.plot(x, result[1], label=result[0])
ax1.legend(loc=0)
ax1.set_xlim([0, 6])
ax1.xaxis.set_major_locator(IndexLocator(1, 0))
ax1.grid(which='major')
ax1.set_xlabel('', visible=False)
ax1.set_ylabel('Compilation time (second)')
for lbl in ax1.get_xticklabels():
lbl.set_visible(False)
ax1.get_yticklabels()[0].set_visible(False)
base = array(results[0][1])
comp = array(results[1][1])
perf = -1 * (comp - base) / base * 100
ymin = []
ymax = []
for r in perf:
if r < 0:
ymin.append(r)
ymax.append(0)
else:
ymin.append(0)
ymax.append(r)
ax2.vlines(x, ymin, ymax, linewidth='10', color='blue')
ax2.xaxis.set_major_locator(IndexLocator(1, 0))
ax2.set_xlim([0, 6])
ax2.grid(which='major')
ax2.set_ylabel('Improvement (%)')
ax2.set_xlabel('Jobs')
ax2.get_yticklabels()[-1].set_visible(False)
for i in range(len(results[0][1])):
print '%3d %9f %9f %9f %6.2f%%' % (i + 1, results[0][1][i], results[1][1][i], results[2][1][i], perf[i])
pyplot.show()