summaryrefslogtreecommitdiff
path: root/docs/client_examples/plot-async-db.py
blob: 018a1a1de70c9c642b6ce5297d912d36796faf3c (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
import csv
from matplotlib import pyplot as plt

FILE = "bench.csv"

# config the plot
plt.xlabel('number of inserts')
plt.ylabel('time (seconds)')
plt.title('SQLCipher parallelization')

kwargs = {
    'linewidth': 1.0,
    'linestyle': '-',
}

series = (('sync', 'r'),
          ('async', 'g'))

data = {'mark': [],
        'sync': [],
        'async': []}

with open(FILE, 'rb') as csvfile:
    series_reader = csv.reader(csvfile, delimiter=',')
    for m, s, a in series_reader:
        data['mark'].append(int(m))
        data['sync'].append(float(s))
        data['async'].append(float(a))

xmax = max(data['mark'])
xmin = min(data['mark'])
ymax = max(data['sync'] + data['async'])
ymin = min(data['sync'] + data['async'])

for run in series:
    name = run[0]
    color = run[1]
    plt.plot(data['mark'], data[name], label=name, color=color, **kwargs)

plt.axes().annotate("", xy=(xmax, ymax))
plt.axes().annotate("", xy=(xmin, ymin))

plt.grid()
plt.legend()
plt.show()