forked from DFHack/dfhack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathattachtest.py
53 lines (36 loc) · 971 Bytes
/
attachtest.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
import time
from pydfhack import ContextManager
df_cm = ContextManager("Memory.xml")
df = None
def test_attach():
global df
if not df:
df = df_cm.get_single_context()
if not df.attach():
print "Unable to attach!"
return False
elif not df.detach():
print "Unabled to detach!"
return False
else:
return True
def suspend_test():
global df
if not df:
df = df_cm.get_single_context()
print "Testing suspend/resume"
df.attach()
t1 = time.time()
for i in xrange(1000):
df.suspend()
if i % 10 == 0:
print "%i%%" % (i / 10.0,)
df.resume()
t2 = time.time()
df.detach()
print "suspend test done in $0.9f seconds" % (t2 - t1)
if __name__ == "__main__":
if test_attach():
suspend_test()
print "Done. Press any key to continue"
raw_input()