Add profile counters for PCB mouse and paint events
This commit is contained in:
parent
a205595404
commit
014bad7b28
|
@ -179,6 +179,8 @@ static const wxChar TraceMasks[] = wxT( "TraceMasks" );
|
|||
|
||||
static const wxChar ShowRepairSchematic[] = wxT( "ShowRepairSchematic" );
|
||||
|
||||
static const wxChar ShowEventCounters[] = wxT( "ShowEventCounters" );
|
||||
|
||||
} // namespace KEYS
|
||||
|
||||
|
||||
|
@ -285,6 +287,7 @@ ADVANCED_CFG::ADVANCED_CFG()
|
|||
m_Skip3DModelFileCache = false;
|
||||
m_Skip3DModelMemoryCache = false;
|
||||
m_HideVersionFromTitle = false;
|
||||
m_ShowEventCounters = false;
|
||||
|
||||
loadFromConfigFile();
|
||||
}
|
||||
|
@ -400,6 +403,9 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg )
|
|||
configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::ShowRepairSchematic,
|
||||
&m_ShowRepairSchematic, false ) );
|
||||
|
||||
configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::ShowEventCounters,
|
||||
&m_ShowEventCounters, false ) );
|
||||
|
||||
// Special case for trace mask setting...we just grab them and set them immediately
|
||||
// Because we even use wxLogTrace inside of advanced config
|
||||
wxString traceMasks = "";
|
||||
|
|
|
@ -71,6 +71,8 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
|
|||
m_parent = aParentWindow;
|
||||
m_MouseCapturedLost = false;
|
||||
|
||||
m_PaintEventCounter = std::make_unique<PROF_COUNTER>( "Draw panel paint events" );
|
||||
|
||||
SetLayoutDirection( wxLayout_LeftToRight );
|
||||
|
||||
m_edaFrame = dynamic_cast<EDA_DRAW_FRAME*>( m_parent );
|
||||
|
@ -190,6 +192,8 @@ void EDA_DRAW_PANEL_GAL::DoRePaint()
|
|||
if( m_drawing )
|
||||
return;
|
||||
|
||||
( *m_PaintEventCounter )++;
|
||||
|
||||
wxASSERT( m_painter );
|
||||
|
||||
m_drawing = true;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
|
||||
#include <pgm_base.h>
|
||||
#include <profile.h>
|
||||
#include <view/view.h>
|
||||
#include <view/wx_view_controls.h>
|
||||
#include <view/zoom_controller.h>
|
||||
|
@ -83,6 +84,8 @@ WX_VIEW_CONTROLS::WX_VIEW_CONTROLS( VIEW* aView, EDA_DRAW_PANEL_GAL* aParentPane
|
|||
{
|
||||
LoadSettings();
|
||||
|
||||
m_MotionEventCounter = std::make_unique<PROF_COUNTER>( "Mouse motion events" );
|
||||
|
||||
m_parentPanel->Connect( wxEVT_MOTION,
|
||||
wxMouseEventHandler( WX_VIEW_CONTROLS::onMotion ), nullptr, this );
|
||||
#if wxCHECK_VERSION( 3, 1, 0 ) || defined( USE_OSX_MAGNIFY_EVENT )
|
||||
|
@ -192,6 +195,8 @@ void WX_VIEW_CONTROLS::LoadSettings()
|
|||
|
||||
void WX_VIEW_CONTROLS::onMotion( wxMouseEvent& aEvent )
|
||||
{
|
||||
( *m_MotionEventCounter )++;
|
||||
|
||||
bool isAutoPanning = false;
|
||||
int x = aEvent.GetX();
|
||||
int y = aEvent.GetY();
|
||||
|
|
|
@ -197,6 +197,11 @@ public:
|
|||
|
||||
bool m_ShowRepairSchematic;
|
||||
|
||||
/**
|
||||
* Shows debugging event counters in various places.
|
||||
*/
|
||||
bool m_ShowEventCounters;
|
||||
|
||||
private:
|
||||
ADVANCED_CFG();
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
class BOARD;
|
||||
class EDA_DRAW_FRAME;
|
||||
class TOOL_DISPATCHER;
|
||||
class PROF_COUNTER;
|
||||
|
||||
namespace KIGFX
|
||||
{
|
||||
|
@ -233,6 +234,8 @@ public:
|
|||
*/
|
||||
bool m_MouseCapturedLost;
|
||||
|
||||
std::unique_ptr<PROF_COUNTER> m_PaintEventCounter;
|
||||
|
||||
protected:
|
||||
virtual void onPaint( wxPaintEvent& WXUNUSED( aEvent ) );
|
||||
void onSize( wxSizeEvent& aEvent );
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#ifndef TPROFILE_H
|
||||
#define TPROFILE_H
|
||||
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
@ -217,4 +218,46 @@ private:
|
|||
*/
|
||||
unsigned GetRunningMicroSecs();
|
||||
|
||||
|
||||
/**
|
||||
* A thread-safe event counter
|
||||
*/
|
||||
class PROF_COUNTER
|
||||
{
|
||||
public:
|
||||
PROF_COUNTER( const std::string& aName ) :
|
||||
m_name( aName ),
|
||||
m_count( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
unsigned long long Count() const
|
||||
{
|
||||
return m_count.load();
|
||||
}
|
||||
|
||||
void Reset()
|
||||
{
|
||||
m_count.store( 0 );
|
||||
}
|
||||
|
||||
unsigned long long operator++( int )
|
||||
{
|
||||
return m_count++;
|
||||
}
|
||||
|
||||
void Show( std::ostream& aStream = std::cerr )
|
||||
{
|
||||
if( m_name.size() )
|
||||
aStream << m_name << ": ";
|
||||
|
||||
aStream << m_count.load();
|
||||
aStream << std::endl;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string m_name;
|
||||
std::atomic_ullong m_count;
|
||||
};
|
||||
|
||||
#endif // TPROFILE_H
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include <memory>
|
||||
|
||||
class EDA_DRAW_PANEL_GAL;
|
||||
class PROF_COUNTER;
|
||||
|
||||
namespace KIGFX
|
||||
{
|
||||
|
@ -115,6 +116,8 @@ public:
|
|||
///< mouse cursor does not move in screen coordinates, but does in world coordinates)
|
||||
static const wxEventType EVT_REFRESH_MOUSE;
|
||||
|
||||
std::unique_ptr<PROF_COUNTER> m_MotionEventCounter;
|
||||
|
||||
private:
|
||||
///< Possible states for WX_VIEW_CONTROLS.
|
||||
enum STATE
|
||||
|
|
|
@ -102,6 +102,8 @@
|
|||
#include <widgets/panel_selection_filter.h>
|
||||
#include <widgets/wx_aui_utils.h>
|
||||
#include <kiplatform/app.h>
|
||||
#include <profile.h>
|
||||
#include <view/wx_view_controls.h>
|
||||
|
||||
#include <action_plugin.h>
|
||||
#include "../scripting/python_scripting.h"
|
||||
|
@ -363,6 +365,27 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
|||
// Ensure the controls on the toolbars all are correctly sized
|
||||
UpdateToolbarControlSizes();
|
||||
} );
|
||||
|
||||
if( ADVANCED_CFG::GetCfg().m_ShowEventCounters )
|
||||
{
|
||||
m_eventCounterTimer = new wxTimer( this );
|
||||
|
||||
Bind( wxEVT_TIMER,
|
||||
[&]( wxTimerEvent& aEvent )
|
||||
{
|
||||
GetCanvas()->m_PaintEventCounter->Show();
|
||||
GetCanvas()->m_PaintEventCounter->Reset();
|
||||
|
||||
KIGFX::WX_VIEW_CONTROLS* vc =
|
||||
static_cast<KIGFX::WX_VIEW_CONTROLS*>( GetCanvas()->GetViewControls() );
|
||||
vc->m_MotionEventCounter->Show();
|
||||
vc->m_MotionEventCounter->Reset();
|
||||
|
||||
},
|
||||
m_eventCounterTimer->GetId() );
|
||||
|
||||
m_eventCounterTimer->Start( 1000 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -785,6 +785,8 @@ private:
|
|||
TOOL_ACTION* m_exportNetlistAction;
|
||||
|
||||
DIALOG_FIND* m_findDialog;
|
||||
|
||||
wxTimer* m_eventCounterTimer;
|
||||
};
|
||||
|
||||
#endif // __PCB_EDIT_FRAME_H__
|
||||
|
|
Loading…
Reference in New Issue