Home › Forum › SOFA › Using SOFA › Timer for specific part of code
Tagged: 64_bits, AdvancedTimer, Computation Time, Execution time, Linux_ubuntu, SOFA_1912, Speed, Timer
- This topic has 5 replies, 2 voices, and was last updated 6 years ago by
Hugo.
-
AuthorPosts
-
17 June 2020 at 09:03 #16655
Derick
BlockedHi, I am new to SOFA and have a question about using the PythonAdvancedTimer.
I was wondering if it’s possible to extract the computation time of specific part of my code (i.e., the calculation of the forces acting on the mechanical object) and compare it with the overall computation time of one simulation time step.
Thanks in advance for any help!
Best,
Derick19 June 2020 at 19:22 #16681Hugo
KeymasterHi @sderick
I am not familiar with this PythonAdvancedTimer.py
It does not seem to be able to be tuned for extraction of a specific part of the simulation. However, this can be achieved using the “Log Time” option in the Stats widget of runSofa (or the Display Advanced Timer).
are you using the GUI or running SOFA in batch?
Best,Hugo
22 June 2020 at 08:49 #16684Derick
BlockedHi Hugo
Thanks for your reply!
I am running SOFA in batch. However, I switched to GUI mode to check out the stats, as you described. This looks very useful. I am curious how to select the substep of my python code so that the computation time can be displayed.
Best
Derick23 June 2020 at 22:50 #16700Hugo
KeymasterHi @sderick
I just would like to confirm my understanding: you would like to measure the time spent in your python script. Is that correct?
Which function(s) are of interest in your script?Hugo
24 June 2020 at 13:21 #16713Derick
BlockedHi,
I am calculating forces acting on a MechanicalObject. These forces come from a magnetic manipulation system and there are custom classes which compute these forces. In the end, I need to check how much time is spent calculating the force versus the time needed for the simulation.
Derick
30 July 2020 at 14:38 #16988Hugo
KeymasterHi @sderick
Sorry for the delay of the reply.
Ok I better understand.I think you can get inspired from what appears in CGLinearSolver (l.114). This ScopedAdvancedTimer will compute the time spent into this function. The value of the timer will be returned when you activate the options: “Log Time” or “Display AdvanceTimer profiler” in the Stats Widget (as shown above).
Hope this helps.
Best
Hugo
-
AuthorPosts
- You must be logged in to reply to this topic.

