koder aka kdanilov | 6c49106 | 2015-04-09 22:33:13 +0300 | [diff] [blame] | 1 | import sys |
| 2 | |
| 3 | import numpy as np |
| 4 | import matplotlib.pyplot as plt |
| 5 | from numpy.polynomial.chebyshev import chebfit, chebval |
| 6 | |
| 7 | from disk_perf_test_tool.tests.io_results_loader import load_data, filter_data |
| 8 | |
| 9 | |
| 10 | def linearity_plot(plt, data, types): |
| 11 | fields = 'blocksize_b', 'iops_mediana', 'iops_stddev' |
| 12 | |
| 13 | names = {} |
| 14 | for tp1 in ('rand', 'seq'): |
| 15 | for oper in ('read', 'write'): |
| 16 | for sync in ('sync', 'direct', 'async'): |
| 17 | sq = (tp1, oper, sync) |
| 18 | name = "{0} {1} {2}".format(*sq) |
| 19 | names["".join(word[0] for word in sq)] = name |
| 20 | |
| 21 | for tp in types: |
| 22 | filtered_data = filter_data('linearity_test_' + tp, fields) |
| 23 | x = [] |
| 24 | y = [] |
| 25 | e = [] |
| 26 | |
| 27 | for sz, med, dev in sorted(filtered_data(data)): |
| 28 | iotime_ms = 1000. // med |
| 29 | iotime_max = 1000. // (med - dev * 3) |
| 30 | |
| 31 | x.append(sz / 1024) |
| 32 | y.append(iotime_ms) |
| 33 | e.append(iotime_max - iotime_ms) |
| 34 | |
| 35 | plt.errorbar(x, y, e, linestyle='None', marker=names[tp]) |
| 36 | plt.legend(loc=2) |
| 37 | |
| 38 | |
| 39 | def th_plot(data, tt): |
| 40 | fields = 'concurence', 'iops_mediana', 'lat_mediana' |
| 41 | conc_4k = filter_data('concurrence_test_' + tt, fields, blocksize='4k') |
| 42 | filtered_data = sorted(list(conc_4k(data))) |
| 43 | |
| 44 | x, iops, lat = zip(*filtered_data) |
| 45 | |
| 46 | _, ax1 = plt.subplots() |
| 47 | |
| 48 | xnew = np.linspace(min(x), max(x), 50) |
| 49 | # plt.plot(xnew, power_smooth, 'b-', label='iops') |
| 50 | ax1.plot(x, iops, 'b*') |
| 51 | |
| 52 | for degree in (3,): |
| 53 | c = chebfit(x, iops, degree) |
| 54 | vals = chebval(xnew, c) |
| 55 | ax1.plot(xnew, vals, 'g--') |
| 56 | |
| 57 | # ax1.set_xlabel('thread count') |
| 58 | # ax1.set_ylabel('iops') |
| 59 | |
| 60 | # ax2 = ax1.twinx() |
| 61 | # lat = [i / 1000 for i in lat] |
| 62 | # ax2.plot(x, lat, 'r*') |
| 63 | |
| 64 | # tck = splrep(x, lat, s=0.0) |
| 65 | # power_smooth = splev(xnew, tck) |
| 66 | # ax2.plot(xnew, power_smooth, 'r-', label='lat') |
| 67 | |
| 68 | # xp = xnew[0] |
| 69 | # yp = power_smooth[0] |
| 70 | # for _x, _y in zip(xnew[1:], power_smooth[1:]): |
| 71 | # if _y >= 100: |
| 72 | # xres = (_y - 100.) / (_y - yp) * (_x - xp) + xp |
| 73 | # ax2.plot([xres, xres], [min(power_smooth), max(power_smooth)], 'g--') |
| 74 | # break |
| 75 | # xp = _x |
| 76 | # yp = _y |
| 77 | |
| 78 | # ax2.plot([min(x), max(x)], [20, 20], 'g--') |
| 79 | # ax2.plot([min(x), max(x)], [100, 100], 'g--') |
| 80 | |
| 81 | # ax2.set_ylabel("lat ms") |
| 82 | # plt.legend(loc=2) |
| 83 | |
| 84 | |
| 85 | def main(argv): |
| 86 | data = list(load_data(open(argv[1]).read())) |
| 87 | # linearity_plot(data) |
| 88 | th_plot(data, 'rws') |
| 89 | # th_plot(data, 'rrs') |
| 90 | plt.show() |
| 91 | |
| 92 | |
| 93 | if __name__ == "__main__": |
| 94 | exit(main(sys.argv)) |