<div dir="ltr">OK. Scratch that, I no longer believe that this is a performance measurement issue, but rather a performance issue. I have replaced my measurement code with the built in StatsHandler class, so my code now looks as follows:<div><br></div><div><div>int main() {</div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>ref_ptr<osgViewer::CompositeViewer> viewer=new osgViewer::CompositeViewer();<br></div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>ref_ptr<osgViewer::View> view1 = new osgViewer::View;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>viewer->addView(view1);<br></div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>view1->addEventHandler( new osgViewer::StatsHandler );<br></div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>return viewer->run();<br></div><div>}</div><div><br></div><div>When I press S statshandler reports 30-40fps. Obviously there is not a lot of room to have messed up in a 5-liner program, so I believe that that is the actual framerate that I am getting. Question is why. I am running on a NVIDIA Geforce 980Ti under Ubuntu 14.04 with nvidia driver version 352.63) . I have optimization on (-O3 under gcc) and believe that I am linking against release libraries not debug ones.</div><div><br></div><div>Any ideas where to look??</div><div><br></div><div>Regards</div><div>Hannes</div><div><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Hannes Naude</b> <span dir="ltr"><<a href="mailto:naude.jj@gmail.com">naude.jj@gmail.com</a>></span><br>Date: Mon, Oct 17, 2016 at 1:46 PM<br>Subject: OSG performance measurement<br>To: OpenSceneGraph Users <<a href="mailto:osg-users@lists.openscenegraph.org">osg-users@lists.openscenegraph.org</a>><br><br><br><div dir="ltr"><div class="gmail_extra">Hi all </div><div class="gmail_extra"><br></div><div class="gmail_extra">New to OSG so apologies if this is a stupid question.</div><div class="gmail_extra"><br></div><div class="gmail_extra">I have written a visualization tool in OSG and as a last step, I wish to ensure that it runs at the screen refresh rate. My perception was that it mostly runs smoothly but stutters every few frames or so, so I wrote code to print the elapsed time between every two frames, rather than just the average framerate. The printout seemed to confirm this, so I gradually removed more and more of my scenegraph, trying to determine where the bottleneck lies. The weird thing is that I end up with a completely empty scenegraph (just rendering a blue screen) and execution time STILL seems to stutter. So, I strongly suspect that there is something fundamentally wrong with the way I am measuring. I realise that FPS is a bad performance metric, but right now I just want to get to the point where I am updating every frame on my hardware and I am not particularly concerned about performance on any other hardware. The remaining code looks like this:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">int main() {</div><div class="gmail_extra"><span class="gmail-m_8011302020802418987gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>ref_ptr<osgViewer::<wbr>CompositeViewer> viewer=new osgViewer::CompositeViewer();<span class="gmail-m_8011302020802418987gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>ref_ptr<osgViewer::View> view1 = new osgViewer::View;<br></div><div class="gmail_extra"><span class="gmail-m_8011302020802418987gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>viewer->addView(view1);<br></div><div class="gmail_extra"><span class="gmail-m_8011302020802418987gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>float timeNow,timePrev=0;<br></div><div class="gmail_extra"><span class="gmail-m_8011302020802418987gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>while (!viewer->done())</div><div class="gmail_extra"><span class="gmail-m_8011302020802418987gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>{</div><div class="gmail_extra"><span class="gmail-m_8011302020802418987gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>viewer->frame();</div><div class="gmail_extra"><span class="gmail-m_8011302020802418987gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>timeNow=osg::Timer::instance()<wbr>->time_s();<br></div><div class="gmail_extra"><span class="gmail-m_8011302020802418987gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>std::cout << timeNow-timePrev << " ";</div><div class="gmail_extra"><span class="gmail-m_8011302020802418987gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>timePrev=timeNow;</div><div class="gmail_extra"><span class="gmail-m_8011302020802418987gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>}</div><div class="gmail_extra"><span class="gmail-m_8011302020802418987gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>return(0);</div><div class="gmail_extra">}<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">and the resulting printout to the console looks like this:</div><div class="gmail_extra"><br></div><div class="gmail_extra">0.123003 0.00298501 0.000751987 0.016045 0.083418 0.038128 0.013075 0.00068298 0.014678 0.019825 0.013804 0.016688 0.01651 0.066802 0.023197 0.07995 0.013019 0.000387967 0.0331 0.000599027 0.03273 0.000575006 0.088067 0.083023...<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">As you can see, the loop occasionally takes as much as 88ms to complete, while at other time completing within 0.6ms. What could possibly be causing this massive variation? </div><div class="gmail_extra"><br></div><div class="gmail_extra">Regards</div><span class="gmail-HOEnZb"><font color="#888888"><div class="gmail_extra">Hannes Naude</div></font></span></div></div>
</div><br></div></div></div>