Skip to content

Commit c6a2e24

Browse files
committed
add script to check init perf
1 parent c3ef2a6 commit c6a2e24

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

examples/test_perf.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import sys
2+
sys.path.insert(0, "..")
3+
import time
4+
5+
6+
from opcua import ua, Server
7+
8+
import cProfile
9+
import re
10+
11+
12+
def mymain():
13+
14+
# setup our server
15+
server = Server()
16+
server.set_endpoint("opc.tcp://0.0.0.0:4840/freeopcua/server/")
17+
18+
# setup our own namespace, not really necessary but should as spec
19+
uri = "http://examples.freeopcua.github.io"
20+
idx = server.register_namespace(uri)
21+
22+
# get Objects node, this is where we should put our nodes
23+
objects = server.get_objects_node()
24+
25+
# populating our address space
26+
myobj = objects.add_object(idx, "MyObject")
27+
myvar = myobj.add_variable(idx, "MyVariable", 6.7)
28+
myvar.set_writable() # Set MyVariable to be writable by clients
29+
30+
# starting!
31+
server.start()
32+
server.stop()
33+
34+
35+
if __name__ == "__main__":
36+
cProfile.run('mymain()')

0 commit comments

Comments
 (0)