[osg-users] querying stats
Werner Modenbach
Werner.Modenbach at modenbach-ac.de
Mon Mar 29 12:31:23 PST 2021
Hi all!
I try querying stats for each frame. Unfortunately all values stay at 0.0. Any Ideas?
here is my code, mainly copied from the StatsHandler:
Initialisation:
#ifdefPROFILE_FRAMES
osgViewer::ViewerBase::Camerascameras;
Viewer::getCameras(cameras);
Viewer::getViewerStats()->collectStats("update",true);
for(osgViewer::ViewerBase::Cameras::iteratoritr=cameras.begin();
itr!=cameras.end();
++itr)
{
if((*itr)->getStats())(*itr)->getStats()->collectStats("rendering",true);
if((*itr)->getStats())(*itr)->getStats()->collectStats("gpu",true);
}
#endif
After each frame the query:
#ifdefPROFILE_FRAMES
osgViewer::ViewerBase::Camerascameras;
Viewer::getCameras(cameras);
intframeNumber=Viewer::getViewerStats()->getLatestFrameNumber();
doubleupdateTime{0.0};
doublerenderingTime{0.0};
doublegpuTime{0.0};
Viewer::getViewerStats()->getAttribute(frameNumber,std::string("update"),updateTime);
for(osgViewer::ViewerBase::Cameras::iteratoritr=cameras.begin();
itr!=cameras.end();
++itr)
{
doubletmp{0.0};
if((*itr)->getStats()){
if((*itr)->getStats()->getAttribute(frameNumber,std::string("rendering"),tmp))
renderingTime+=tmp;
if((*itr)->getStats()->getAttribute(frameNumber,std::string("gpu"),tmp))
gpuTime+=tmp;
}
}
std::cout<<"update:"<<std::fixed<<std::setprecision(2)<<updateTime*1000.0
<<"ms\trendering:"<<std::fixed<<std::setprecision(2)<<renderingTime*1000.0
<<"ms\tgpu:"<<std::fixed<<std::setprecision(2)<<gpuTime*1000.0<<"ms"<<std::endl;
#endif
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20210329/64b1dccf/attachment.html>
More information about the osg-users
mailing list