-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlaunch-voodoo
executable file
·132 lines (103 loc) · 2.35 KB
/
launch-voodoo
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
#!/usr/bin/env python3
import IPython
import cProfile
# pr = cProfile.Profile()
# pr.enable()
import blng.Voodoo
# pr.disable()
# pr.print_stats()
# pr = cProfile.Profile()
# pr.enable()
session = blng.Voodoo.DataAccess('crux-example.xml')
vcache = session._keystorecache
scache = session._schemacache
schema = session._schema
xmldoc = session._xmldoc
xmlstr = """<crux-vooodoo>
<simpleleaf old_value="9998">9999</simpleleaf>
<morecomplex>
<leaf2>a</leaf2>
</morecomplex>
<simplelist>
<simplekey listkey="yes">firstkey</simplekey>
</simplelist>
<hyphen-leaf>abc123</hyphen-leaf>
<outsidelist>
<leafo listkey="yes">a</leafo>
<insidelist>
<leafi listkey="yes">A</leafi>
</insidelist>
</outsidelist>
<outsidelist>
<leafo listkey="yes">b</leafo>
</outsidelist>
</crux-vooodoo>"""
# pr.disable()
# pr.print_stats()
# pr = cProfile.Profile()
# pr.enable()
root = session.get_root()
# pr.disable()
# pr.print_stats()
pr = None
def start_profile():
global pr
pr = cProfile.Profile()
pr.enable()
def stop_profile():
global pr
pr.disable()
pr.print_stats()
print("""
session (dumps(), loads())
vache = Value Cache (indexed by xpath)
scache = Schema Cache (indexed by xpath)
schema = Schema XML DOC (Crux Format)
xmldoc = Value XML DOC
root = Voodo - root api
xmlstr = xmlstring (output of dumps())
Example Profiling (not within ipython):
start_profile()
# DO STUFF
stop_profile()
""")
"""
# pr = cProfile.Profile()
# pr.enable()
root.simpleleaf = 'Hello World!'
# pr.disable()
# pr.print_stats()
pr = cProfile.Profile()
pr.enable()
print(session.dumps())
pr.disable()
pr.print_stats()
root.morecomplex.leaf2 = "a"
import time
n = 10000
start_time = time.time()
for x in range(n):
root.simpleleaf = str(x)
end_time = time.time()
print((end_time-start_time), 'for', n)
print((end_time-start_time)/n)
a = end_time-start_time
xmldoc = session._xmldoc
# start_time = time.time()
# for x in range(n):
# e = xmldoc.xpath('//simpleleaf')[0] = str(x)
# end_time = time.time()
# print((end_time-start_time), 'for', n)
# print((end_time-start_time)/n)
# b = end_time-start_time
# e = xmldoc.xpath('//simpleleaf')[0]
# start_time = time.time()
# for x in range(n):
# e = str(x)
# end_time = time.time()
# print((end_time-start_time), 'for', n)
# print((end_time-start_time)/n)
# c = end_time-start_time
# print((a/b)*100)
"""
IPython.embed(display_banner=False)