How to log time
From SOFAWiki
Presentation of the different ways to log the time spent.
Contents |
Simple Timer
TODO
Advanced Timer
TODO
Trace Visitor
TODO A graphic tool using Qt exists, and is integrated inside the Sofa main application to trace and profile the execution of the visitors in Sofa. Tips#Trace_and_Profiling
How to enable the trace of the visitors
You need to activate the option SOFA_DUMP_VISITOR_INFO in your sofa configuration. It should be enabled by default. If not, you can use SofaVerification to modify the configuration of Sofa.
Quickly find information
To find a specific visitor, or a call to a component, you can use the search bar:
View State vectors
An other interesting feature is the possibility to trace the evolution of the state vectors:
Just enable the option, and specify the number of particles; -1 meaning all the particles
Here, we trace the particles numero 2 and 3. A FixedConstraint acts in this scene on the particle 3: it filters its velocity and acceleration, and set it to zero, to act as a fixed particle. We can visualize the effect of the ApplyConstraint visitor on the state vector.
Add new debug information
Trace specific part of the code
To trace and profile the execution of a part of your program, put, at the beginning of the code to profile:
simulation::Visitor::printNode("NameMethod");
and at end the process
simulation::Visitor::printCloseNode("NameMethod");
The method printNode can take other arguments to get a more detailed log;
sofa::simulation::Visitor::TRACE_ARGUMENT arg; arg.push_back(std::make_pair("ArgumentName", "Value")); sofa::simulation::Visitor::printNode("MyDebug", arg); //.... sofa::simulation::Visitor::printCloseNode("MyDebug");
Trace an additional state vector
At any time in your code, you can monitor a state vector of a given mechanical state writting:
if (sofa::simulation::Visitor::IsExportStateVectorEnabled()) { sofa::simulation::Visitor::printNode("MyDebug"); sofa::simulation::Visitor::printVector(mstate, id); //mstate is a ptr to a mechanical state, id is a VecId, indicating the state vector sofa::simulation::Visitor::printCloseNode("MyDebug"); }

