From: Lucas De Marchi Date: Fri, 16 Aug 2013 03:47:36 +0000 (-0300) Subject: parse-depmod: Allow to plot all at once X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3cdd70349ef5cff684ff482ac2ff8efef4717af9;p=thirdparty%2Fkmod.git parse-depmod: Allow to plot all at once --- diff --git a/scripts/parse-depmod b/scripts/parse-depmod index 3ff8a8bc..47539697 100755 --- a/scripts/parse-depmod +++ b/scripts/parse-depmod @@ -1,7 +1,7 @@ #!/usr/bin/python import sys - +import os.path def parse_table(f): curr = 0 @@ -36,23 +36,31 @@ def add_at(ax, t, loc=2): ax.add_artist(_at) return _at -fig = plt.figure() - -with open(sys.argv[1]) as f: - for i in range(0, 3): - x, y = parse_table(f) - fit = np.polyfit(x, y, 1) - fit_fn = np.poly1d(fit) - - ax = fig.add_subplot(2, 2, i, axisbg='#f6f6f6') - ax.plot(x, y, 'b', x, fit_fn(x), 'r') - ax.set_xlabel('bucket') - ax.set_ylabel('entries') - ax.axis('tight') - add_at(ax, 'mean=%.2f\nstddev=%.2f' % (np.mean(y), np.std(y))) - ax.grid(True) - -fig.suptitle('Hash distribution on buckets', weight='bold', size='large') -fig.tight_layout() -plt.subplots_adjust(top=0.9) + +figs = [] +for fn in sys.argv[1:]: + fig = plt.figure() + figs += [fig] + + with open(fn) as f: + for i in range(0, 3): + x, y = parse_table(f) + fit = np.polyfit(x, y, 1) + fit_fn = np.poly1d(fit) + + ax = fig.add_subplot(2, 2, i, axisbg='#f6f6f6') + ax.plot(x, y, 'b', x, fit_fn(x), 'r') + ax.set_xlabel('bucket') + ax.set_ylabel('entries') + ax.axis('tight') + add_at(ax, 'mean=%.2f\nstddev=%.2f' % (np.mean(y), np.std(y))) + ax.grid(True) + + tit = os.path.splitext(os.path.basename(fn))[0] + fig.suptitle('Hash distribution on buckets: %s' % tit, weight='bold', + size='large') + fig.tight_layout() + fig.subplots_adjust(top=0.9) + + plt.show()