-
Notifications
You must be signed in to change notification settings - Fork 0
/
throughput_C_A_B.py
48 lines (37 loc) · 1.46 KB
/
throughput_C_A_B.py
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
import matplotlib.pyplot as plt
import os
# def parse()
command = "LD_PRELOAD=./libjemalloc.so taskset -c 0-15 ./benchmark.out -a {} -sT {} -sR 10000000 -m 50000 -t 16"
def expriment():
tableSizes = [1000, 10000, 100000, 1000000]
times = list(range(0, 50000, 1000))
algorithms = ['B', 'C']
results = dict.fromkeys(algorithms)
for algorithm in algorithms:
results[algorithm] = dict.fromkeys(tableSizes)
for tableSize in tableSizes:
for algorithm in algorithms:
cmd = command.format(algorithm, tableSize)
cmd += " | awk -F\' \' \'{if($3 == \"throughput\" ) print $2}\' "
output = os.popen(cmd).read()
throughputs = list(map(float, output.split('\n')[:-1]))
print(algorithm, throughputs)
results[algorithm][tableSize] = throughputs[:50]
fig, axes = plt.subplots(2, 2, figsize=(12, 7))
axes = axes.ravel()
fig.tight_layout(pad=2.5)
print(results)
for algo in algorithms:
algo_res = results[algo]
for index,tableSize in enumerate(tableSizes):
ax = axes[index]
ax.plot(times, algo_res[tableSize], label=algo)
for index, ax in enumerate(axes):
ax.set_title(f'table_size({tableSizes[index]})')
ax.set_ylabel("throughput")
ax.set_xlabel("time(milliseconds)")
ax.grid(True)
ax.legend()
plt.savefig("B-C.png")
print(results)
expriment()