summaryrefslogtreecommitdiff
path: root/scripts/parse-depmod
blob: 87cd31c5dc5a748c47166295f308bcb354731d05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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()