diff options
Diffstat (limited to 'scripts/parse-depmod')
-rwxr-xr-x | scripts/parse-depmod | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/scripts/parse-depmod b/scripts/parse-depmod new file mode 100755 index 0000000..87cd31c --- /dev/null +++ b/scripts/parse-depmod @@ -0,0 +1,52 @@ +#!/usr/bin/python + +import sys + + +def parse_table(f): + curr = 0 + x = [] + y = [] + + while (True): + line = f.readline() + + if line == '#####\n': + if curr == 3: + break + else: + curr += 1 + elif curr == 2: + v = [int(i) for i in line.strip().split()] + x += [v[0]] + y += [v[1]] + return x, y + +import matplotlib.pyplot as plt +import numpy as np + +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) + ax.plot(x, y, 'b', x, fit_fn(x), 'r') + ax.set_xlabel('bucket') + ax.set_ylabel('entries') + ax.axis('tight') + ax.text(0.03, 0.97, + 'mean=%.2f\nstddev=%.2f' % (np.mean(y), np.std(y)), + transform=ax.transAxes, + verticalalignment='top', + horizontalalignment='left' + ) + ax.grid(True) + +fig.suptitle('Hash distribution on buckets', weight='bold', size='large') +fig.tight_layout() +plt.subplots_adjust(top=0.9) +plt.show() |