-
Notifications
You must be signed in to change notification settings - Fork 11
/
benchmark_n1ql.py
79 lines (62 loc) · 1.5 KB
/
benchmark_n1ql.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
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
#!/usr/bin/env python
import cProfile
import pstats
import StringIO
from multiprocessing import Value
from spring.wgen import WorkloadGen
workload_settings = type(
'WorkloadSettings',
(object, ),
{
'creates': 0,
'reads': 0,
'updates': 100,
'deletes': 0,
'cases': 0,
'ops': 100,
'throughput': float('inf'),
'size': 2048,
'items': 10000,
'expiration': 0,
'working_set': 100,
'working_set_access': 100,
'doc_gen': 'new',
'workers': 0,
'query_workers': 0,
'dcp_workers': 0,
'n1ql': None,
'n1ql_workers': 1,
'n1ql_throughput': 10,
'n1ql_queries': [{
'statement': 'SELECT * FROM `{bucket}` USE KEYS(\"{key}\")',
'max-parallel': 1
}]
}
)()
target_settings = type(
'TargetSettings',
(object, ),
{
'node': '127.0.0.1:8091',
'bucket': 'default',
'password': '',
'prefix': None,
}
)
def run():
curr_items = Value('i', workload_settings.items)
deleted_items = Value('i', 0)
workload = WorkloadGen(workload_settings, target_settings)
workload.run()
def profile():
pr = cProfile.Profile()
s = StringIO.StringIO()
pr.enable()
run()
pr.disable()
ps = pstats.Stats(pr, stream=s).sort_stats('tottime')
ps.reverse_order()
ps.print_stats()
ps.dump_stats('profile.prof')
if __name__ == '__main__':
profile()