Home › Forum › SOFA › Programming with SOFA › [SOLVED] execution time
Tagged: 64_bits, Linux_ubuntu, SOFA_1706
- This topic has 4 replies, 4 voices, and was last updated 5 years, 10 months ago by Damien Marchal.
-
AuthorPosts
-
7 January 2019 at 13:06 #12730ZahraBlocked
Hi,
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:
https://gist.github.com/zbounik/b4f0bb124ac23591c07f7d406bdc29af
This is the L1v.msh file to be loaded:
https://gist.github.com/zbounik/3b2bba7207d5a835c54f754943b2071band this is the “time_controller” that I have added as an object of rootnode in my main script:
https://gist.github.com/zbounik/3b1b880dc73e8a4e93bbe62f787c2cc5Thanks in advance for any help,
best,
Zahra9 January 2019 at 15:23 #12746HugoKeymaster10 January 2019 at 11:52 #12752ZahraBlockedDear @Hugo,
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?
Best,
Zahra10 January 2019 at 18:54 #12757HugoKeymasterDear @zahra,
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:
export SOFA_TIMER_ALL=1
this will activate all these timer computations. (set =0 to desactivate it)
BestHugo
16 January 2019 at 13:57 #12790Damien MarchalBlockedHi,
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:
https://www.sofa-framework.org/api/master/plugins/SofaPython/html/md__media_jenkins_sofa-ci-dev_workspace_generate-doxygen_master_sofa_applications_plugins_SofaPython_doc_AdvancedTimer_readMe.htmlBut I personally prefer to use the low level API that directly interact with the timing functions available in the Sofa module.
https://github.com/sofa-framework/sofa/blob/master/applications/plugins/SofaPython/python/SofaPython/PythonAdvancedTimer.pyHope this helps and, in case you think that the documentation is not clear, don’t hesitate to propose improvements we welcome any help.
Regards,
Damien. -
AuthorPosts
- You must be logged in to reply to this topic.