Commit 7a8e1fc6 authored by Maciej Suminski's avatar Maciej Suminski

Different way of measuring render time.

parent 7a1718d0
...@@ -39,6 +39,10 @@ ...@@ -39,6 +39,10 @@
#include <gal/opengl/opengl_gal.h> #include <gal/opengl/opengl_gal.h>
#include <gal/cairo/cairo_gal.h> #include <gal/cairo/cairo_gal.h>
#ifdef __WXDEBUG__
#include <profile.h>
#endif /* __WXDEBUG__ */
#define METRIC_UNIT_LENGTH (1e9) #define METRIC_UNIT_LENGTH (1e9)
...@@ -116,6 +120,12 @@ void EDA_DRAW_PANEL_GAL::onSize( wxSizeEvent& aEvent ) ...@@ -116,6 +120,12 @@ void EDA_DRAW_PANEL_GAL::onSize( wxSizeEvent& aEvent )
void EDA_DRAW_PANEL_GAL::Refresh( bool eraseBackground, const wxRect* rect ) 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->BeginDrawing();
m_gal->SetBackgroundColor( KiGfx::COLOR4D( 0, 0, 0, 1.0 ) ); m_gal->SetBackgroundColor( KiGfx::COLOR4D( 0, 0, 0, 1.0 ) );
m_gal->ClearScreen(); m_gal->ClearScreen();
...@@ -129,6 +139,13 @@ void EDA_DRAW_PANEL_GAL::Refresh( bool eraseBackground, const wxRect* rect ) ...@@ -129,6 +139,13 @@ void EDA_DRAW_PANEL_GAL::Refresh( bool eraseBackground, const wxRect* rect )
m_view->Redraw(); m_view->Redraw();
m_gal->EndDrawing(); m_gal->EndDrawing();
#ifdef __WXDEBUG__
prof_end( &time );
wxLogDebug( wxT( "EDA_DRAW_PANEL_GAL::Refresh: %.0f ms (%.0f fps)" ),
static_cast<double>( time.value ) / 1000.0, 1000000.0 / static_cast<double>( time.value ) );
#endif /* __WXDEBUG__ */
} }
......
...@@ -33,7 +33,9 @@ ...@@ -33,7 +33,9 @@
#include <gal/graphics_abstraction_layer.h> #include <gal/graphics_abstraction_layer.h>
#include <painter.h> #include <painter.h>
#ifdef __WXDEBUG__
#include <profile.h> #include <profile.h>
#endif /* __WXDEBUG__ */
using namespace KiGfx; using namespace KiGfx;
...@@ -359,14 +361,12 @@ void VIEW::EnableTopLayer( bool aEnable ) ...@@ -359,14 +361,12 @@ void VIEW::EnableTopLayer( bool aEnable )
struct VIEW::drawItem struct VIEW::drawItem
{ {
drawItem( VIEW* aView, int aCurrentLayer ) : drawItem( VIEW* aView, int aCurrentLayer ) :
count( 0 ), countCached( 0 ), currentLayer( aCurrentLayer ), time( 0 ), view( aView ) currentLayer( aCurrentLayer ), view( aView )
{ {
} }
void operator()( VIEW_ITEM* aItem ) void operator()( VIEW_ITEM* aItem )
{ {
BOX2I tmp;
uint64_t ts = rdtsc();
GAL* gal = view->GetGAL(); GAL* gal = view->GetGAL();
if( view->m_useGroups ) if( view->m_useGroups )
...@@ -376,7 +376,6 @@ struct VIEW::drawItem ...@@ -376,7 +376,6 @@ struct VIEW::drawItem
if( group >= 0 && aItem->ViewIsVisible() ) if( group >= 0 && aItem->ViewIsVisible() )
{ {
gal->DrawGroup( group ); gal->DrawGroup( group );
countCached++;
} }
else else
{ {
...@@ -390,30 +389,15 @@ struct VIEW::drawItem ...@@ -390,30 +389,15 @@ struct VIEW::drawItem
{ {
view->m_painter->Draw( static_cast<EDA_ITEM*>( aItem ), currentLayer ); view->m_painter->Draw( static_cast<EDA_ITEM*>( aItem ), currentLayer );
} }
time += rdtsc() - ts;
count++;
} }
int count;
int countCached;
int currentLayer; int currentLayer;
uint64_t time;
VIEW* view; VIEW* view;
}; };
void VIEW::redrawRect( const BOX2I& aRect ) 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 ) BOOST_FOREACH( VIEW_LAYER* l, m_orderedLayers )
{ {
if( l->enabled ) if( l->enabled )
...@@ -421,25 +405,11 @@ void VIEW::redrawRect( const BOX2I& aRect ) ...@@ -421,25 +405,11 @@ void VIEW::redrawRect( const BOX2I& aRect )
drawItem drawFunc( this, l->id ); drawItem drawFunc( this, l->id );
if( !m_useGroups ) if( !m_useGroups )
m_gal->SetLayerDepth( (double) l->renderingOrder ); m_gal->SetLayerDepth( static_cast<double>( l->renderingOrder ) );
l->items->Query( aRect, drawFunc ); l->items->Query( aRect, drawFunc );
l->isDirty = false; 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__ */
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment