#!/usr/bin/python import os import matplotlib.pyplot as plt try: myfullpath = os.path.dirname(os.path.realpath(__file__)) except NameError: myfullpath = os.path.abspath(os.path.curdir) def convert_to_MB(value, unit): if unit == 'kB/s': return value/1000. if unit == 'MB/s': return value if unit == 'GB/s': return value*1000. su = ['65536', '131072', '262144', '524288'] bs = ['64k', '128k', '256k', '512k'] cl = ['ds-001', 'ds-004', 'ds-517', 'ds-518'] su_v = ['64', '128', '256', '512'] ms = ['bs', 'g^', 'co', 'pr'] nj = ['50', '100', '150', '200'] sp = ['221', '222', '223', '224'] for i in range(len(cl)): plt.figure(i) for l in range(len(nj)): plt.subplot(sp[l]) plt.tight_layout() for j in range(len(bs)): bw_plt = [] for k in range(len(su)): fn = os.path.join(myfullpath, 'test_fio_%s_su_%s_bs_%s_nj_%s/fio_test.log' % (cl[i], su[k], bs[j], nj[l])) if os.path.isfile(fn): f = open(fn, 'r') lines = list(f) value = '0' unit = 'kB/s' if "WRITE: bw=" in lines[-1]: value = lines[-1].split("(")[1].split(")")[0][:-4] unit = lines[-1].split("(")[1].split(")")[0][-4:] bw_plt.append(convert_to_MB(float(value), unit)) if len(bw_plt) == len(su_v): plt.plot(su_v, bw_plt, ms[j], label=('bs=%s' % bs[j])) plt.legend(loc='upper left', prop={'size': 6}) plt.title('%s jobs' % nj[l]) plt.ylabel('BandWidth (MB/s)') plt.xlabel('stripe unit (kiB)') plt.grid(True) plt.savefig('%s.pdf' % cl[i]) plt.savefig('%s.png' % cl[i]) plt.close(i) plt.figure(4) for l in range(len(nj)): plt.subplot(sp[l]) plt.tight_layout() for j in range(len(bs)): bw_plt = [] for k in range(len(su)): bw_tot = 0. for i in range(len(cl)): fn = os.path.join(myfullpath, 'test_fio_%s_su_%s_bs_%s_nj_%s/fio_test.log' % (cl[i], su[k], bs[j], nj[l])) if os.path.isfile(fn): f = open(fn, 'r') lines = list(f) value = '0' unit = 'kB/s' if "WRITE: bw=" in lines[-1]: value = lines[-1].split("(")[1].split(")")[0][:-4] unit = lines[-1].split("(")[1].split(")")[0][-4:] bw_tot += convert_to_MB(float(value), unit) bw_plt.append(bw_tot) if len(bw_plt) == len(su_v): plt.plot(su_v, bw_plt, ms[j], label=('bs=%s' % bs[j])) plt.legend(loc='upper left', prop={'size': 6}) plt.title('%s jobs' % nj[l]) plt.ylabel('BandWidth (MB/s)') plt.xlabel('stripe unit (kiB)') plt.grid(True) title = 'cumulative' plt.savefig('%s.pdf' % title) plt.savefig('%s.png' % title) plt.close(4)