-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtest.py
More file actions
executable file
·142 lines (120 loc) · 4 KB
/
test.py
File metadata and controls
executable file
·142 lines (120 loc) · 4 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/home/mengxing/anaconda3/bin//python
#
# @Author: liumx10
# @Date: 2018-04-17 21:45:42
# @Last Modified by: liumx10
# @Last Modified time: 2018-07-29 15:16:29
#
import os
import sys
import getopt
import numpy as np
TEST_TIME = 3
TREE_SIZE = 24
def runtest(latency, tree, benchmark, initkeys, thread, workload, skewness, scan_length, read_ratio):
duration = 0.1 if benchmark == 3 else 5
command = "NVM_LATENCY={} ./build/benchmark -n {} -t {} -b {} -k {} -d {} -w {} -S {} -l {} -r {}|\
grep -Eo '([0-9]*\.[0-9]*) Mtps'".format(
latency, thread, tree, benchmark, initkeys, duration, workload, skewness, scan_length, read_ratio)
# print(command)
r = os.popen(command)
for line in r.readlines():
words = line.split()
return float(words[0])
def multi_times_test(latency, tree, benchmark, initkeys, thread=1, workload=0, skewness=0.99, scan_length=10, read_ratio=50):
result = []
for i in range(0, TEST_TIME):
res = runtest(latency, tree, benchmark, initkeys, thread, workload, skewness, scan_length, read_ratio)
result.append(res)
print(latency, thread, tree, benchmark, initkeys, np.average(result))
return np.average(result), np.max(result), np.min(result)
def single():
print("single thread test")
f = open("singlethread.csv", "w")
for latency in [0]:
f.write('[\n')
for tree in [6,5,2,0,1]:
f.write('[')
for benchmark in range(0, 5):
f.write(str(multi_times_test(latency, tree, benchmark, TREE_SIZE)[0]))
f.write(',')
f.write(']\n')
f.write(']\n')
f.close()
def find():
print("differen work size for find")
f = open("find.csv", "w")
for tree in [0, 3, 2]:
f.write('[')
for k in [14, 16, 18, 20, 22, 24, 26]:
f.write(str(multi_times_test(0, tree, 0, k)[0]))
f.write(',')
f.write(']\n')
def multicore():
print("multiply thread test")
f = open("multithread.csv", "w")
for workload in [0]:
f.write('[\n')
for tree in [1, 2, 3]:
f.write('[')
for thread in [1, 2, 4, 8, 16, 24]:
f.write(str(multi_times_test(0, tree, 5, 20, thread, workload, 0.8, 10, 50)[0]))
f.write(',')
f.write(']\n')
f.write(']\n')
f.close()
def skew():
print("skew test")
f = open("skew.csv", "w")
for tree in [1, 2, 3]:
f.write('[')
for s in [0.55, 0.6, 0.65, 0.68, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 0.99]:
f.write(str(multi_times_test(0, tree, 5, 20, 8, 1, s)[0]))
f.write(',')
f.write(']\n')
f.close()
def scan():
print("scan test")
f = open("scan.csv", "w")
for tree in [0, 2, 3]:
f.write('[')
#for length in [20]:
for length in [5, 10, 50, 100, 200, 500, 1000]:
f.write(str(multi_times_test(0, tree, 10, 20, 1, 0, 0, length)[0]))
f.write(',')
f.write('],\n')
def read_ratio():
print("read/update ratio test")
f = open("read_ratio.csv", "w")
for tree in [1, 2, 3]:
f.write('[')
for r in range(10, 100, 10):
f.write(str(multi_times_test(0, tree, 5, 20, 22, 1, 0.7, read_ratio=r)[0]))
f.write(",")
f.write('],')
def main():
try:
options, args = getopt.getopt(sys.argv[1:], "sfmSlr", ["single", "find", "multicore", "skew", "scan", "read"])
except:
sys.exit()
for name, value in options:
if name in ('-s', '--single'):
single()
sys.exit()
if name in ('-f', '--find'):
find()
sys.exit()
if name in ('-S', '--skew'):
skew()
sys.exit()
if name in ('-m', '--multicore'):
multicore()
sys.exit()
if name in ('-l', '--scan'):
scan()
sys.exit()
if name in ('-r', '--read'):
read_ratio()
sys.exit()
if __name__ == "__main__":
main()