From 1d0ca225726bfaaef31eae1baabc2e0b9ff7d152 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Thu, 16 May 2013 17:17:35 +0200 Subject: [PATCH] Different way of measuring render time. --- common/drawpanel_gal.cpp | 17 +++++++++++++++++ common/view/view.cpp | 38 ++++---------------------------------- 2 files changed, 21 insertions(+), 34 deletions(-) diff --git a/common/drawpanel_gal.cpp b/common/drawpanel_gal.cpp index 7e8cf7acf6..e82f5f3553 100644 --- a/common/drawpanel_gal.cpp +++ b/common/drawpanel_gal.cpp @@ -39,6 +39,10 @@ #include #include +#ifdef __WXDEBUG__ +#include +#endif /* __WXDEBUG__ */ + #define METRIC_UNIT_LENGTH (1e9) @@ -116,6 +120,12 @@ void EDA_DRAW_PANEL_GAL::onSize( wxSizeEvent& aEvent ) void EDA_DRAW_PANEL_GAL::Refresh( bool eraseBackground, const wxRect* rect ) { +#ifdef __WXDEBUG__ + prof_counter time; + + prof_start( &time, false ); +#endif /* __WXDEBUG__ */ + m_gal->BeginDrawing(); m_gal->SetBackgroundColor( KiGfx::COLOR4D( 0, 0, 0, 1.0 ) ); m_gal->ClearScreen(); @@ -129,6 +139,13 @@ void EDA_DRAW_PANEL_GAL::Refresh( bool eraseBackground, const wxRect* rect ) m_view->Redraw(); m_gal->EndDrawing(); + +#ifdef __WXDEBUG__ + prof_end( &time ); + + wxLogDebug( wxT( "EDA_DRAW_PANEL_GAL::Refresh: %.0f ms (%.0f fps)" ), + static_cast( time.value ) / 1000.0, 1000000.0 / static_cast( time.value ) ); +#endif /* __WXDEBUG__ */ } diff --git a/common/view/view.cpp b/common/view/view.cpp index 5e250373fe..26188e3d86 100644 --- a/common/view/view.cpp +++ b/common/view/view.cpp @@ -33,7 +33,9 @@ #include #include +#ifdef __WXDEBUG__ #include +#endif /* __WXDEBUG__ */ using namespace KiGfx; @@ -359,14 +361,12 @@ void VIEW::EnableTopLayer( bool aEnable ) struct VIEW::drawItem { drawItem( VIEW* aView, int aCurrentLayer ) : - count( 0 ), countCached( 0 ), currentLayer( aCurrentLayer ), time( 0 ), view( aView ) + currentLayer( aCurrentLayer ), view( aView ) { } void operator()( VIEW_ITEM* aItem ) { - BOX2I tmp; - uint64_t ts = rdtsc(); GAL* gal = view->GetGAL(); if( view->m_useGroups ) @@ -376,7 +376,6 @@ struct VIEW::drawItem if( group >= 0 && aItem->ViewIsVisible() ) { gal->DrawGroup( group ); - countCached++; } else { @@ -390,30 +389,15 @@ struct VIEW::drawItem { view->m_painter->Draw( static_cast( aItem ), currentLayer ); } - - time += rdtsc() - ts; - count++; } - int count; - int countCached; int currentLayer; - uint64_t time; VIEW* view; }; void VIEW::redrawRect( const BOX2I& aRect ) { - int totalItems = 0, totalCached = 0; - uint64_t totalDrawTime = 0; -#ifdef __WXDEBUG__ - prof_counter totalCycles, totalRealTime; - - prof_start( &totalRealTime, false ); - prof_start( &totalCycles, true ); -#endif /* __WXDEBUG__ */ - BOOST_FOREACH( VIEW_LAYER* l, m_orderedLayers ) { if( l->enabled ) @@ -421,25 +405,11 @@ void VIEW::redrawRect( const BOX2I& aRect ) drawItem drawFunc( this, l->id ); if( !m_useGroups ) - m_gal->SetLayerDepth( (double) l->renderingOrder ); + m_gal->SetLayerDepth( static_cast( l->renderingOrder ) ); l->items->Query( aRect, drawFunc ); l->isDirty = false; - - totalItems += drawFunc.count; - totalDrawTime += drawFunc.time; - totalCached += drawFunc.countCached; } } - -#ifdef __WXDEBUG__ - prof_end( &totalCycles ); - prof_end( &totalRealTime ); - - wxLogDebug( wxT( "Redraw::items %d (%d cached), %.1f ms/frame (%.0f FPS), draw/geometry ratio: %.1f%%" ), - totalItems, totalCached, (double) totalRealTime.value / 1000.0, - 1000000.0 / (double) totalRealTime.value, - (double) totalDrawTime / (double) totalCycles.value * 100.0 ); -#endif /* __WXDEBUG__ */ }