Skip to content

Commit 57debb4

Browse files
committed
add test
1 parent 8afeef2 commit 57debb4

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import Sofa
2+
3+
g_nb_controllers = 10
4+
g_nb_steps = 10000
5+
6+
class EmptyController(Sofa.Core.Controller):
7+
8+
def __init__(self, *args, **kwargs):
9+
Sofa.Core.Controller.__init__(self, *args, **kwargs)
10+
11+
# Default Events *********************************************
12+
def onAnimateBeginEvent(self, event): # called at each begin of animation step
13+
# print(f"{self.name.value} : onAnimateBeginEvent")
14+
pass
15+
16+
def createScene(root):
17+
root.dt = 0.01
18+
root.bbox = [[-1, -1, -1], [1, 1, 1]]
19+
root.addObject('DefaultVisualManagerLoop')
20+
root.addObject('DefaultAnimationLoop')
21+
22+
23+
for i in range(g_nb_controllers):
24+
root.addObject(EmptyController(name=f"MyEmptyController{i}"))
25+
26+
27+
def main():
28+
root = Sofa.Core.Node("root")
29+
createScene(root)
30+
Sofa.Simulation.initRoot(root)
31+
32+
# Import the time library
33+
import time
34+
start = time.time()
35+
for iteration in range(g_nb_steps):
36+
Sofa.Simulation.animate(root, root.dt.value)
37+
end = time.time()
38+
39+
print(f"Scene with {g_nb_controllers} controllers and {g_nb_steps} steps took {end - start} seconds.")
40+
41+
print("End of simulation.")
42+
43+
44+
if __name__ == '__main__':
45+
main()

0 commit comments

Comments
 (0)