7 January 2019 at 13 h 06 min #12730ZahraParticipant
How can I measure the execution time of a sofa python script? I imported the “time”, and I considered the start of the time in “onBeginAnimationStep” and end of the time in “onBeginAnimationStep”, but it is not working correctly.
This is my script:
This is the L1v.msh file to be loaded:
and this is the “time_controller” that I have added as an object of rootnode in my main script:
Thanks in advance for any help,
Zahra9 January 2019 at 15 h 23 min #12746HugoKeymaster
10 January 2019 at 11 h 52 min #12752ZahraParticipant
- SOFA Consortium
Thank you for suggesting the AdvancedTimer. I read the explanation but I didn’t understand how to use it.
Where should I add “-c $INT” to activate the option in runSofa?
Also, I do not understand how I should use this:
sofa::helper::AdvancedTimer::stepBegin(“Build linear equation”);
Is it to be used in a c++ code?
Isn’t there any equivalent command in python?
Zahra10 January 2019 at 18 h 54 min #12757HugoKeymaster
- SOFA Consortium
AdvancedTimer has time be placed in the c++ code to keep track/compute the time spent on specific part of the simulation. Not sure about python equivalent, but I guess their are dedicated libs. What I know is working is to set in your environment variable:
this will activate all these timer computations. (set =0 to desactivate it)
Hugo16 January 2019 at 13 h 57 min #12790Damien MarchalParticipant
- CNRS/Defrost Team
When the timing are activated with the SOFA_TIMER_ALL some statistic will be visible for python scripts. But all the scripts instance will be aggregated.
To differentiate between instances you need to do that manually using the python binding of the timing API.
There is some basic documentation of the high level API there:
But I personally prefer to use the low level API that directly interact with the timing functions available in the Sofa module.
Hope this helps and, in case you think that the documentation is not clear, don’t hesitate to propose improvements we welcome any help.
- You must be logged in to reply to this topic.