53 lines
1.2 KiB
Python
Executable File
53 lines
1.2 KiB
Python
Executable File
#!/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()
|