News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Performance measurement of all C::B event handlers

Started by ollydbg, June 01, 2013, 12:37:21 PM

Previous topic - Next topic

ollydbg

Hi, this is the patch:

Index: include/cbfunctor.h
===================================================================
--- include/cbfunctor.h (revision 9090)
+++ include/cbfunctor.h (working copy)
@@ -12,6 +12,7 @@
public:
virtual ~IFunctorBase(){}
virtual void* GetThis() = 0;
+ virtual const char* GetTypeName() = 0;
};

/** Base abstract event functor class. All event functors must extend this interface.*/
@@ -33,6 +34,7 @@
cbEventFunctor(const cbEventFunctor<ClassType, EventType>& rhs) : m_pThis(rhs.m_pThis), m_pMember(rhs.m_pMember) {}
virtual void* GetThis() { return m_pThis; }
virtual void Call(EventType& event) { if (m_pThis) (m_pThis->*m_pMember)(event); }
+ virtual const char* GetTypeName(){return __PRETTY_FUNCTION__;}
};

#endif // CB_FUNCTOR_H
Index: sdk/manager.cpp
===================================================================
--- sdk/manager.cpp (revision 9090)
+++ sdk/manager.cpp (working copy)
@@ -177,7 +177,73 @@
    if (mit != m_EventSinks.end())
    {
        for (EventSinksArray::iterator it = mit->second.begin(); it != mit->second.end(); ++it)
+        {
+            wxStopWatch sw;
            (*it)->Call(event);
+            const char *p = (*it)->GetTypeName();
+            wxString msg = wxString::FromUTF8(p);
+
+            wxEventType type=event.GetEventType();
+            if(type==cbEVT_APP_STARTUP_DONE) msg.Append(_("cbEVT_APP_STARTUP_DONE"));
+            else if(type==cbEVT_APP_START_SHUTDOWN) msg.Append(_("cbEVT_APP_START_SHUTDOWN"));
+            else if(type==cbEVT_APP_ACTIVATED) msg.Append(_("cbEVT_APP_ACTIVATED"));
+            else if(type==cbEVT_APP_DEACTIVATED) msg.Append(_("cbEVT_APP_DEACTIVATED"));
+            else if(type==cbEVT_PLUGIN_ATTACHED) msg.Append(_("cbEVT_PLUGIN_ATTACHED"));
+            else if(type==cbEVT_PLUGIN_RELEASED) msg.Append(_("cbEVT_PLUGIN_RELEASED"));
+            else if(type==cbEVT_PLUGIN_INSTALLED) msg.Append(_("cbEVT_PLUGIN_INSTALLED"));
+            else if(type==cbEVT_PLUGIN_UNINSTALLED) msg.Append(_("cbEVT_PLUGIN_UNINSTALLED"));
+            else if(type==cbEVT_PLUGIN_LOADING_COMPLETE) msg.Append(_("cbEVT_PLUGIN_LOADING_COMPLETE"));
+            else if(type==cbEVT_EDITOR_CLOSE) msg.Append(_("cbEVT_EDITOR_CLOSE"));
+            else if(type==cbEVT_EDITOR_OPEN) msg.Append(_("cbEVT_EDITOR_OPEN"));
+            else if(type==cbEVT_EDITOR_SWITCHED) msg.Append(_("cbEVT_EDITOR_SWITCHED"));
+            else if(type==cbEVT_EDITOR_ACTIVATED) msg.Append(_("cbEVT_EDITOR_ACTIVATED"));
+            else if(type==cbEVT_EDITOR_DEACTIVATED) msg.Append(_("cbEVT_EDITOR_DEACTIVATED"));
+            else if(type==cbEVT_EDITOR_BEFORE_SAVE) msg.Append(_("cbEVT_EDITOR_BEFORE_SAVE"));
+            else if(type==cbEVT_EDITOR_SAVE) msg.Append(_("cbEVT_EDITOR_SAVE"));
+            else if(type==cbEVT_EDITOR_MODIFIED) msg.Append(_("cbEVT_EDITOR_MODIFIED"));
+            else if(type==cbEVT_EDITOR_TOOLTIP) msg.Append(_("cbEVT_EDITOR_TOOLTIP"));
+            else if(type==cbEVT_EDITOR_TOOLTIP_CANCEL) msg.Append(_("cbEVT_EDITOR_TOOLTIP_CANCEL"));
+            else if(type==cbEVT_EDITOR_UPDATE_UI) msg.Append(_("cbEVT_EDITOR_UPDATE_UI"));
+            else if(type==cbEVT_PROJECT_NEW) msg.Append(_("cbEVT_PROJECT_NEW"));
+            else if(type==cbEVT_PROJECT_CLOSE) msg.Append(_("cbEVT_PROJECT_CLOSE"));
+            else if(type==cbEVT_PROJECT_OPEN) msg.Append(_("cbEVT_PROJECT_OPEN"));
+            else if(type==cbEVT_PROJECT_SAVE) msg.Append(_("cbEVT_PROJECT_SAVE"));
+            else if(type==cbEVT_PROJECT_ACTIVATE) msg.Append(_("cbEVT_PROJECT_ACTIVATE"));
+            else if(type==cbEVT_PROJECT_BEGIN_ADD_FILES) msg.Append(_("cbEVT_PROJECT_BEGIN_ADD_FILES"));
+            else if(type==cbEVT_PROJECT_END_ADD_FILES) msg.Append(_("cbEVT_PROJECT_END_ADD_FILES"));
+            else if(type==cbEVT_PROJECT_BEGIN_REMOVE_FILES) msg.Append(_("cbEVT_PROJECT_BEGIN_REMOVE_FILES"));
+            else if(type==cbEVT_PROJECT_END_REMOVE_FILES) msg.Append(_("cbEVT_PROJECT_END_REMOVE_FILES"));
+            else if(type==cbEVT_PROJECT_FILE_ADDED) msg.Append(_("cbEVT_PROJECT_FILE_ADDED"));
+            else if(type==cbEVT_PROJECT_FILE_REMOVED) msg.Append(_("cbEVT_PROJECT_FILE_REMOVED"));
+            else if(type==cbEVT_PROJECT_POPUP_MENU) msg.Append(_("cbEVT_PROJECT_POPUP_MENU"));
+            else if(type==cbEVT_PROJECT_TARGETS_MODIFIED) msg.Append(_("cbEVT_PROJECT_TARGETS_MODIFIED"));
+            else if(type==cbEVT_PROJECT_RENAMED) msg.Append(_("cbEVT_PROJECT_RENAMED"));
+            else if(type==cbEVT_WORKSPACE_CHANGED) msg.Append(_("cbEVT_WORKSPACE_CHANGED"));
+            else if(type==cbEVT_BUILDTARGET_ADDED) msg.Append(_("cbEVT_BUILDTARGET_ADDED"));
+            else if(type==cbEVT_BUILDTARGET_REMOVED) msg.Append(_("cbEVT_BUILDTARGET_REMOVED"));
+            else if(type==cbEVT_BUILDTARGET_RENAMED) msg.Append(_("cbEVT_BUILDTARGET_RENAMED"));
+            else if(type==cbEVT_BUILDTARGET_SELECTED) msg.Append(_("cbEVT_BUILDTARGET_SELECTED"));
+            else if(type==cbEVT_PIPEDPROCESS_STDOUT) msg.Append(_("cbEVT_PIPEDPROCESS_STDOUT"));
+            else if(type==cbEVT_PIPEDPROCESS_STDERR) msg.Append(_("cbEVT_PIPEDPROCESS_STDERR"));
+            else if(type==cbEVT_PIPEDPROCESS_TERMINATED) msg.Append(_("cbEVT_PIPEDPROCESS_TERMINATED"));
+            else if(type==cbEVT_THREADTASK_STARTED) msg.Append(_("cbEVT_THREADTASK_STARTED"));
+            else if(type==cbEVT_THREADTASK_ENDED) msg.Append(_("cbEVT_THREADTASK_ENDED"));
+            else if(type==cbEVT_THREADTASK_ALLDONE) msg.Append(_("cbEVT_THREADTASK_ALLDONE"));
+            else if(type==cbEVT_MENUBAR_CREATE_BEGIN) msg.Append(_("cbEVT_MENUBAR_CREATE_BEGIN"));
+            else if(type==cbEVT_MENUBAR_CREATE_END) msg.Append(_("cbEVT_MENUBAR_CREATE_END"));
+            else if(type==cbEVT_COMPILER_STARTED) msg.Append(_("cbEVT_COMPILER_STARTED"));
+            else if(type==cbEVT_COMPILER_FINISHED) msg.Append(_("cbEVT_COMPILER_FINISHED"));
+            else if(type==cbEVT_COMPILER_SET_BUILD_OPTIONS) msg.Append(_("cbEVT_COMPILER_SET_BUILD_OPTIONS"));
+            else if(type==cbEVT_CLEAN_PROJECT_STARTED) msg.Append(_("cbEVT_CLEAN_PROJECT_STARTED"));
+            else if(type==cbEVT_CLEAN_WORKSPACE_STARTED) msg.Append(_("cbEVT_CLEAN_WORKSPACE_STARTED"));
+            else if(type==cbEVT_DEBUGGER_STARTED) msg.Append(_("cbEVT_DEBUGGER_STARTED"));
+            else if(type==cbEVT_DEBUGGER_STARTED) msg.Append(_("cbEVT_DEBUGGER_STARTED"));
+            else if(type==cbEVT_DEBUGGER_PAUSED) msg.Append(_("cbEVT_DEBUGGER_PAUSED"));
+            else if(type==cbEVT_DEBUGGER_FINISHED) msg.Append(_("cbEVT_DEBUGGER_FINISHED"));
+            else msg.Append(_("unknown CodeBlocksEvent"));
+            if(sw.Time() > 10) // only print a handler run longer than 10 ms
+                wxLogMessage(wxT("%s take %ld ms"), msg.wx_str(), sw.Time());
+        }
    }
    return true;
}
Index: src/main.cpp
===================================================================
--- src/main.cpp (revision 9090)
+++ src/main.cpp (working copy)
@@ -557,6 +557,7 @@
       m_pScriptConsole(0),
       m_pBatchBuildDialog(0)
{
+    wxLog::SetActiveTarget(new wxLogStderr());
    Manager::Get(this); // provide manager with handle to MainFrame (this)

    // register event sinks

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

ollydbg

#1
New patch, I use typeid and demangle function.

Index: include/cbfunctor.h
===================================================================
--- include/cbfunctor.h (revision 9090)
+++ include/cbfunctor.h (working copy)
@@ -5,13 +5,14 @@

#ifndef CB_FUNCTOR_H
#define CB_FUNCTOR_H
-
+#include <typeinfo>
/** Base abstract functor class. All functors must extend this interface. */
class IFunctorBase
{
public:
virtual ~IFunctorBase(){}
virtual void* GetThis() = 0;
+ virtual const char* GetTypeName() = 0;
};

/** Base abstract event functor class. All event functors must extend this interface.*/
@@ -33,6 +34,7 @@
cbEventFunctor(const cbEventFunctor<ClassType, EventType>& rhs) : m_pThis(rhs.m_pThis), m_pMember(rhs.m_pMember) {}
virtual void* GetThis() { return m_pThis; }
virtual void Call(EventType& event) { if (m_pThis) (m_pThis->*m_pMember)(event); }
+ virtual const char* GetTypeName(){return typeid(m_pMember).name();}
};

#endif // CB_FUNCTOR_H
Index: sdk/manager.cpp
===================================================================
--- sdk/manager.cpp (revision 9090)
+++ sdk/manager.cpp (working copy)
@@ -37,6 +37,9 @@
#include <wx/toolbar.h>
#include <wx/fs_mem.h>

+#include <cxxabi.h>
+#include <cstdlib>
+
#include "cbcolourmanager.h"
#include "debuggermanager.h"

@@ -177,7 +180,76 @@
    if (mit != m_EventSinks.end())
    {
        for (EventSinksArray::iterator it = mit->second.begin(); it != mit->second.end(); ++it)
+        {
+            wxStopWatch sw;
            (*it)->Call(event);
+            const char *p = (*it)->GetTypeName();
+            int   status;
+            char *realname;
+            realname = abi::__cxa_demangle(p, 0, 0, &status);
+            wxString msg = wxString::FromUTF8(realname);
+            free(realname);
+            wxEventType type=event.GetEventType();
+            if(type==cbEVT_APP_STARTUP_DONE) msg.Append(_("cbEVT_APP_STARTUP_DONE"));
+            else if(type==cbEVT_APP_START_SHUTDOWN) msg.Append(_("cbEVT_APP_START_SHUTDOWN"));
+            else if(type==cbEVT_APP_ACTIVATED) msg.Append(_("cbEVT_APP_ACTIVATED"));
+            else if(type==cbEVT_APP_DEACTIVATED) msg.Append(_("cbEVT_APP_DEACTIVATED"));
+            else if(type==cbEVT_PLUGIN_ATTACHED) msg.Append(_("cbEVT_PLUGIN_ATTACHED"));
+            else if(type==cbEVT_PLUGIN_RELEASED) msg.Append(_("cbEVT_PLUGIN_RELEASED"));
+            else if(type==cbEVT_PLUGIN_INSTALLED) msg.Append(_("cbEVT_PLUGIN_INSTALLED"));
+            else if(type==cbEVT_PLUGIN_UNINSTALLED) msg.Append(_("cbEVT_PLUGIN_UNINSTALLED"));
+            else if(type==cbEVT_PLUGIN_LOADING_COMPLETE) msg.Append(_("cbEVT_PLUGIN_LOADING_COMPLETE"));
+            else if(type==cbEVT_EDITOR_CLOSE) msg.Append(_("cbEVT_EDITOR_CLOSE"));
+            else if(type==cbEVT_EDITOR_OPEN) msg.Append(_("cbEVT_EDITOR_OPEN"));
+            else if(type==cbEVT_EDITOR_SWITCHED) msg.Append(_("cbEVT_EDITOR_SWITCHED"));
+            else if(type==cbEVT_EDITOR_ACTIVATED) msg.Append(_("cbEVT_EDITOR_ACTIVATED"));
+            else if(type==cbEVT_EDITOR_DEACTIVATED) msg.Append(_("cbEVT_EDITOR_DEACTIVATED"));
+            else if(type==cbEVT_EDITOR_BEFORE_SAVE) msg.Append(_("cbEVT_EDITOR_BEFORE_SAVE"));
+            else if(type==cbEVT_EDITOR_SAVE) msg.Append(_("cbEVT_EDITOR_SAVE"));
+            else if(type==cbEVT_EDITOR_MODIFIED) msg.Append(_("cbEVT_EDITOR_MODIFIED"));
+            else if(type==cbEVT_EDITOR_TOOLTIP) msg.Append(_("cbEVT_EDITOR_TOOLTIP"));
+            else if(type==cbEVT_EDITOR_TOOLTIP_CANCEL) msg.Append(_("cbEVT_EDITOR_TOOLTIP_CANCEL"));
+            else if(type==cbEVT_EDITOR_UPDATE_UI) msg.Append(_("cbEVT_EDITOR_UPDATE_UI"));
+            else if(type==cbEVT_PROJECT_NEW) msg.Append(_("cbEVT_PROJECT_NEW"));
+            else if(type==cbEVT_PROJECT_CLOSE) msg.Append(_("cbEVT_PROJECT_CLOSE"));
+            else if(type==cbEVT_PROJECT_OPEN) msg.Append(_("cbEVT_PROJECT_OPEN"));
+            else if(type==cbEVT_PROJECT_SAVE) msg.Append(_("cbEVT_PROJECT_SAVE"));
+            else if(type==cbEVT_PROJECT_ACTIVATE) msg.Append(_("cbEVT_PROJECT_ACTIVATE"));
+            else if(type==cbEVT_PROJECT_BEGIN_ADD_FILES) msg.Append(_("cbEVT_PROJECT_BEGIN_ADD_FILES"));
+            else if(type==cbEVT_PROJECT_END_ADD_FILES) msg.Append(_("cbEVT_PROJECT_END_ADD_FILES"));
+            else if(type==cbEVT_PROJECT_BEGIN_REMOVE_FILES) msg.Append(_("cbEVT_PROJECT_BEGIN_REMOVE_FILES"));
+            else if(type==cbEVT_PROJECT_END_REMOVE_FILES) msg.Append(_("cbEVT_PROJECT_END_REMOVE_FILES"));
+            else if(type==cbEVT_PROJECT_FILE_ADDED) msg.Append(_("cbEVT_PROJECT_FILE_ADDED"));
+            else if(type==cbEVT_PROJECT_FILE_REMOVED) msg.Append(_("cbEVT_PROJECT_FILE_REMOVED"));
+            else if(type==cbEVT_PROJECT_POPUP_MENU) msg.Append(_("cbEVT_PROJECT_POPUP_MENU"));
+            else if(type==cbEVT_PROJECT_TARGETS_MODIFIED) msg.Append(_("cbEVT_PROJECT_TARGETS_MODIFIED"));
+            else if(type==cbEVT_PROJECT_RENAMED) msg.Append(_("cbEVT_PROJECT_RENAMED"));
+            else if(type==cbEVT_WORKSPACE_CHANGED) msg.Append(_("cbEVT_WORKSPACE_CHANGED"));
+            else if(type==cbEVT_BUILDTARGET_ADDED) msg.Append(_("cbEVT_BUILDTARGET_ADDED"));
+            else if(type==cbEVT_BUILDTARGET_REMOVED) msg.Append(_("cbEVT_BUILDTARGET_REMOVED"));
+            else if(type==cbEVT_BUILDTARGET_RENAMED) msg.Append(_("cbEVT_BUILDTARGET_RENAMED"));
+            else if(type==cbEVT_BUILDTARGET_SELECTED) msg.Append(_("cbEVT_BUILDTARGET_SELECTED"));
+            else if(type==cbEVT_PIPEDPROCESS_STDOUT) msg.Append(_("cbEVT_PIPEDPROCESS_STDOUT"));
+            else if(type==cbEVT_PIPEDPROCESS_STDERR) msg.Append(_("cbEVT_PIPEDPROCESS_STDERR"));
+            else if(type==cbEVT_PIPEDPROCESS_TERMINATED) msg.Append(_("cbEVT_PIPEDPROCESS_TERMINATED"));
+            else if(type==cbEVT_THREADTASK_STARTED) msg.Append(_("cbEVT_THREADTASK_STARTED"));
+            else if(type==cbEVT_THREADTASK_ENDED) msg.Append(_("cbEVT_THREADTASK_ENDED"));
+            else if(type==cbEVT_THREADTASK_ALLDONE) msg.Append(_("cbEVT_THREADTASK_ALLDONE"));
+            else if(type==cbEVT_MENUBAR_CREATE_BEGIN) msg.Append(_("cbEVT_MENUBAR_CREATE_BEGIN"));
+            else if(type==cbEVT_MENUBAR_CREATE_END) msg.Append(_("cbEVT_MENUBAR_CREATE_END"));
+            else if(type==cbEVT_COMPILER_STARTED) msg.Append(_("cbEVT_COMPILER_STARTED"));
+            else if(type==cbEVT_COMPILER_FINISHED) msg.Append(_("cbEVT_COMPILER_FINISHED"));
+            else if(type==cbEVT_COMPILER_SET_BUILD_OPTIONS) msg.Append(_("cbEVT_COMPILER_SET_BUILD_OPTIONS"));
+            else if(type==cbEVT_CLEAN_PROJECT_STARTED) msg.Append(_("cbEVT_CLEAN_PROJECT_STARTED"));
+            else if(type==cbEVT_CLEAN_WORKSPACE_STARTED) msg.Append(_("cbEVT_CLEAN_WORKSPACE_STARTED"));
+            else if(type==cbEVT_DEBUGGER_STARTED) msg.Append(_("cbEVT_DEBUGGER_STARTED"));
+            else if(type==cbEVT_DEBUGGER_STARTED) msg.Append(_("cbEVT_DEBUGGER_STARTED"));
+            else if(type==cbEVT_DEBUGGER_PAUSED) msg.Append(_("cbEVT_DEBUGGER_PAUSED"));
+            else if(type==cbEVT_DEBUGGER_FINISHED) msg.Append(_("cbEVT_DEBUGGER_FINISHED"));
+            else msg.Append(_("unknown CodeBlocksEvent"));
+            if(sw.Time() > 10) // only print a handler run longer than 10 ms
+                wxLogMessage(wxT("%s take %ld ms"), msg.wx_str(), sw.Time());
+        }
    }
    return true;
}
Index: src/main.cpp
===================================================================
--- src/main.cpp (revision 9090)
+++ src/main.cpp (working copy)
@@ -557,6 +557,7 @@
       m_pScriptConsole(0),
       m_pBatchBuildDialog(0)
{
+    wxLog::SetActiveTarget(new wxLogStderr());
    Manager::Get(this); // provide manager with handle to MainFrame (this)

    // register event sinks




Here is the result:
Quote
20:56:51: void (MainFrame::*)(CodeBlocksEvent&)cbEVT_PLUGIN_ATTACHED take 16 ms
20:56:53: void (MainFrame::*)(CodeBlocksEvent&)cbEVT_PLUGIN_ATTACHED take 31 ms
20:56:53: void (MainFrame::*)(CodeBlocksEvent&)cbEVT_PLUGIN_ATTACHED take 32 ms
20:56:53: void (MainFrame::*)(CodeBlocksEvent&)cbEVT_PLUGIN_ATTACHED take 31 ms
20:56:53: void (DebuggerManager::*)(CodeBlocksEvent&)cbEVT_PLUGIN_LOADING_COMPLE
TE take 15 ms
20:57:20: void (DebuggerManager::*)(CodeBlocksEvent&)cbEVT_PROJECT_ACTIVATE take
78 ms
20:57:20: void (CodeCompletion::*)(CodeBlocksEvent&)cbEVT_PROJECT_ACTIVATE take
328 ms
You see: CodeCompletion plugin sometime takes more than 300ms. ;)
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

oBFusCATed

It will be better to make function which converts the type to string instead of using the massive switch.
This is of course if you want to commit the patch to trunk...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

ollydbg

Quote from: oBFusCATed on June 01, 2013, 05:46:08 PM
It will be better to make function which converts the type to string instead of using the massive switch.
This is of course if you want to commit the patch to trunk...
OK, I will add two functions: wxEVT_SCI_XXX to string, and cbEVT_XXXX to string later.
Now, I have measurement for both for editor hook(wx Scintilla event hook), and cbEvent, this is the new patch:

Index: include/cbfunctor.h
===================================================================
--- include/cbfunctor.h (revision 9090)
+++ include/cbfunctor.h (working copy)
@@ -5,13 +5,14 @@

#ifndef CB_FUNCTOR_H
#define CB_FUNCTOR_H
-
+#include <typeinfo>
/** Base abstract functor class. All functors must extend this interface. */
class IFunctorBase
{
public:
virtual ~IFunctorBase(){}
virtual void* GetThis() = 0;
+ virtual const char* GetTypeName() = 0;
};

/** Base abstract event functor class. All event functors must extend this interface.*/
@@ -33,6 +34,7 @@
cbEventFunctor(const cbEventFunctor<ClassType, EventType>& rhs) : m_pThis(rhs.m_pThis), m_pMember(rhs.m_pMember) {}
virtual void* GetThis() { return m_pThis; }
virtual void Call(EventType& event) { if (m_pThis) (m_pThis->*m_pMember)(event); }
+ virtual const char* GetTypeName(){return typeid(m_pMember).name();}
};

#endif // CB_FUNCTOR_H
Index: include/editor_hooks.h
===================================================================
--- include/editor_hooks.h (revision 9090)
+++ include/editor_hooks.h (working copy)
@@ -7,6 +7,7 @@
#define EDITOR_HOOKS_H

#include "settings.h"
+#include <typeinfo>

class cbEditor;
class cbSmartIndentPlugin;
@@ -21,6 +22,7 @@
         public:
             virtual ~HookFunctorBase(){}
             virtual void Call(cbEditor*, wxScintillaEvent&) const = 0;
+            virtual const char* GetTypeName() const = 0;
     };

     /** Functor class for use as a editor modification operations hook.
@@ -48,6 +50,10 @@
                 if (m_pObj && m_pFunc)
                     (m_pObj->*m_pFunc)(editor, event);
             }
+            virtual const char* GetTypeName() const
+            {
+                return typeid(m_pFunc).name();
+            }
         protected:
             T* m_pObj;
             Func m_pFunc;
@@ -91,6 +97,10 @@
               * @param event  The wxScintilla event fired to react accordingly (see cbEditor::CreateEditor, namely scintilla_events)
               */
             virtual void Call(cbEditor* editor, wxScintillaEvent& event) const;
+            virtual const char* GetTypeName() const
+            {
+                return typeid(m_plugin).name();
+            }
         private:
             cbSmartIndentPlugin* m_plugin;
     };
Index: sdk/editor_hooks.cpp
===================================================================
--- sdk/editor_hooks.cpp (revision 9090)
+++ sdk/editor_hooks.cpp (working copy)
@@ -14,6 +14,9 @@
     #include "cbplugin.h"
#endif

+#include <cxxabi.h>
+#include <cstdlib>
+
#include "editor_hooks.h"

#include "wx/wxscintilla.h"
@@ -66,7 +69,51 @@
     {
         EditorHooks::HookFunctorBase* functor = it->second;
         if (functor)
+        {
+            wxStopWatch sw;
             functor->Call(editor, event);
+            if(sw.Time() < 10) // only print a handler run longer than 10 ms
+                continue;
+
+            const char *p = functor->GetTypeName();
+            int   status;
+            char *realname;
+            realname = abi::__cxa_demangle(p, 0, 0, &status);
+            wxString txt = wxString::FromUTF8(realname);
+            free(realname);
+            wxEventType type = event.GetEventType();
+            if (type == wxEVT_SCI_CHANGE) txt << _T("wxEVT_SCI_CHANGE");
+            else if (type == wxEVT_SCI_STYLENEEDED) txt << _T("wxEVT_SCI_STYLENEEDED");
+            else if (type == wxEVT_SCI_CHARADDED) txt << _T("wxEVT_SCI_CHARADDED");
+            else if (type == wxEVT_SCI_SAVEPOINTREACHED) txt << _T("wxEVT_SCI_SAVEPOINTREACHED");
+            else if (type == wxEVT_SCI_SAVEPOINTLEFT) txt << _T("wxEVT_SCI_SAVEPOINTLEFT");
+            else if (type == wxEVT_SCI_ROMODIFYATTEMPT) txt << _T("wxEVT_SCI_ROMODIFYATTEMPT");
+            else if (type == wxEVT_SCI_KEY) txt << _T("wxEVT_SCI_KEY");
+            else if (type == wxEVT_SCI_DOUBLECLICK) txt << _T("wxEVT_SCI_DOUBLECLICK");
+            else if (type == wxEVT_SCI_UPDATEUI) txt << _T("wxEVT_SCI_UPDATEUI");
+            else if (type == wxEVT_SCI_MODIFIED) txt << _T("wxEVT_SCI_MODIFIED");
+            else if (type == wxEVT_SCI_MACRORECORD) txt << _T("wxEVT_SCI_MACRORECORD");
+            else if (type == wxEVT_SCI_MARGINCLICK) txt << _T("wxEVT_SCI_MARGINCLICK");
+            else if (type == wxEVT_SCI_NEEDSHOWN) txt << _T("wxEVT_SCI_NEEDSHOWN");
+            else if (type == wxEVT_SCI_PAINTED) txt << _T("wxEVT_SCI_PAINTED");
+            else if (type == wxEVT_SCI_USERLISTSELECTION) txt << _T("wxEVT_SCI_USERLISTSELECTION");
+            else if (type == wxEVT_SCI_URIDROPPED) txt << _T("wxEVT_SCI_URIDROPPED");
+            else if (type == wxEVT_SCI_DWELLSTART) txt << _T("wxEVT_SCI_DWELLSTART");
+            else if (type == wxEVT_SCI_DWELLEND) txt << _T("wxEVT_SCI_DWELLEND");
+            else if (type == wxEVT_SCI_START_DRAG) txt << _T("wxEVT_SCI_START_DRAG");
+            else if (type == wxEVT_SCI_DRAG_OVER) txt << _T("wxEVT_SCI_DRAG_OVER");
+            else if (type == wxEVT_SCI_DO_DROP) txt << _T("wxEVT_SCI_DO_DROP");
+            else if (type == wxEVT_SCI_ZOOM) txt << _T("wxEVT_SCI_ZOOM");
+            else if (type == wxEVT_SCI_HOTSPOT_CLICK) txt << _T("wxEVT_SCI_HOTSPOT_CLICK");
+            else if (type == wxEVT_SCI_HOTSPOT_DCLICK) txt << _T("wxEVT_SCI_HOTSPOT_DCLICK");
+            else if (type == wxEVT_SCI_CALLTIP_CLICK) txt << _T("wxEVT_SCI_CALLTIP_CLICK");
+            else if (type == wxEVT_SCI_AUTOCOMP_SELECTION) txt << _T("wxEVT_SCI_AUTOCOMP_SELECTION");
+            else if (type == wxEVT_SCI_INDICATOR_CLICK) txt << _T("wxEVT_SCI_INDICATOR_CLICK");
+            else if (type == wxEVT_SCI_INDICATOR_RELEASE) txt << _T("wxEVT_SCI_INDICATOR_RELEASE");
+
+            wxLogMessage(wxT("%s take %ld ms"), txt.wx_str(), sw.Time());
+        }
+
     }
}

Index: sdk/manager.cpp
===================================================================
--- sdk/manager.cpp (revision 9090)
+++ sdk/manager.cpp (working copy)
@@ -37,6 +37,9 @@
#include <wx/toolbar.h>
#include <wx/fs_mem.h>

+#include <cxxabi.h>
+#include <cstdlib>
+
#include "cbcolourmanager.h"
#include "debuggermanager.h"

@@ -177,7 +180,89 @@
     if (mit != m_EventSinks.end())
     {
         for (EventSinksArray::iterator it = mit->second.begin(); it != mit->second.end(); ++it)
+        {
+            wxStopWatch sw;
+
             (*it)->Call(event);
+
+            if(sw.Time() > 10) // only print a handler run longer than 10 ms
+            {
+                const char *p = (*it)->GetTypeName();
+                int   status;
+                char *realname;
+                realname = abi::__cxa_demangle(p, 0, 0, &status);
+                wxString msg;
+                if (realname != 0)
+                {
+                    msg = wxString::FromUTF8(realname);
+                    free(realname);
+                }
+                else
+                    msg = wxString::FromUTF8(p);
+
+                wxEventType type=event.GetEventType();
+                if(type==cbEVT_APP_STARTUP_DONE) msg.Append(_("cbEVT_APP_STARTUP_DONE"));
+                else if(type==cbEVT_APP_START_SHUTDOWN) msg.Append(_("cbEVT_APP_START_SHUTDOWN"));
+                else if(type==cbEVT_APP_ACTIVATED) msg.Append(_("cbEVT_APP_ACTIVATED"));
+                else if(type==cbEVT_APP_DEACTIVATED) msg.Append(_("cbEVT_APP_DEACTIVATED"));
+                else if(type==cbEVT_PLUGIN_ATTACHED) msg.Append(_("cbEVT_PLUGIN_ATTACHED"));
+                else if(type==cbEVT_PLUGIN_RELEASED) msg.Append(_("cbEVT_PLUGIN_RELEASED"));
+                else if(type==cbEVT_PLUGIN_INSTALLED) msg.Append(_("cbEVT_PLUGIN_INSTALLED"));
+                else if(type==cbEVT_PLUGIN_UNINSTALLED) msg.Append(_("cbEVT_PLUGIN_UNINSTALLED"));
+                else if(type==cbEVT_PLUGIN_LOADING_COMPLETE) msg.Append(_("cbEVT_PLUGIN_LOADING_COMPLETE"));
+                else if(type==cbEVT_EDITOR_CLOSE) msg.Append(_("cbEVT_EDITOR_CLOSE"));
+                else if(type==cbEVT_EDITOR_OPEN) msg.Append(_("cbEVT_EDITOR_OPEN"));
+                else if(type==cbEVT_EDITOR_SWITCHED) msg.Append(_("cbEVT_EDITOR_SWITCHED"));
+                else if(type==cbEVT_EDITOR_ACTIVATED) msg.Append(_("cbEVT_EDITOR_ACTIVATED"));
+                else if(type==cbEVT_EDITOR_DEACTIVATED) msg.Append(_("cbEVT_EDITOR_DEACTIVATED"));
+                else if(type==cbEVT_EDITOR_BEFORE_SAVE) msg.Append(_("cbEVT_EDITOR_BEFORE_SAVE"));
+                else if(type==cbEVT_EDITOR_SAVE) msg.Append(_("cbEVT_EDITOR_SAVE"));
+                else if(type==cbEVT_EDITOR_MODIFIED) msg.Append(_("cbEVT_EDITOR_MODIFIED"));
+                else if(type==cbEVT_EDITOR_TOOLTIP) msg.Append(_("cbEVT_EDITOR_TOOLTIP"));
+                else if(type==cbEVT_EDITOR_TOOLTIP_CANCEL) msg.Append(_("cbEVT_EDITOR_TOOLTIP_CANCEL"));
+                else if(type==cbEVT_EDITOR_UPDATE_UI) msg.Append(_("cbEVT_EDITOR_UPDATE_UI"));
+                else if(type==cbEVT_PROJECT_NEW) msg.Append(_("cbEVT_PROJECT_NEW"));
+                else if(type==cbEVT_PROJECT_CLOSE) msg.Append(_("cbEVT_PROJECT_CLOSE"));
+                else if(type==cbEVT_PROJECT_OPEN) msg.Append(_("cbEVT_PROJECT_OPEN"));
+                else if(type==cbEVT_PROJECT_SAVE) msg.Append(_("cbEVT_PROJECT_SAVE"));
+                else if(type==cbEVT_PROJECT_ACTIVATE) msg.Append(_("cbEVT_PROJECT_ACTIVATE"));
+                else if(type==cbEVT_PROJECT_BEGIN_ADD_FILES) msg.Append(_("cbEVT_PROJECT_BEGIN_ADD_FILES"));
+                else if(type==cbEVT_PROJECT_END_ADD_FILES) msg.Append(_("cbEVT_PROJECT_END_ADD_FILES"));
+                else if(type==cbEVT_PROJECT_BEGIN_REMOVE_FILES) msg.Append(_("cbEVT_PROJECT_BEGIN_REMOVE_FILES"));
+                else if(type==cbEVT_PROJECT_END_REMOVE_FILES) msg.Append(_("cbEVT_PROJECT_END_REMOVE_FILES"));
+                else if(type==cbEVT_PROJECT_FILE_ADDED) msg.Append(_("cbEVT_PROJECT_FILE_ADDED"));
+                else if(type==cbEVT_PROJECT_FILE_REMOVED) msg.Append(_("cbEVT_PROJECT_FILE_REMOVED"));
+                else if(type==cbEVT_PROJECT_POPUP_MENU) msg.Append(_("cbEVT_PROJECT_POPUP_MENU"));
+                else if(type==cbEVT_PROJECT_TARGETS_MODIFIED) msg.Append(_("cbEVT_PROJECT_TARGETS_MODIFIED"));
+                else if(type==cbEVT_PROJECT_RENAMED) msg.Append(_("cbEVT_PROJECT_RENAMED"));
+                else if(type==cbEVT_WORKSPACE_CHANGED) msg.Append(_("cbEVT_WORKSPACE_CHANGED"));
+                else if(type==cbEVT_BUILDTARGET_ADDED) msg.Append(_("cbEVT_BUILDTARGET_ADDED"));
+                else if(type==cbEVT_BUILDTARGET_REMOVED) msg.Append(_("cbEVT_BUILDTARGET_REMOVED"));
+                else if(type==cbEVT_BUILDTARGET_RENAMED) msg.Append(_("cbEVT_BUILDTARGET_RENAMED"));
+                else if(type==cbEVT_BUILDTARGET_SELECTED) msg.Append(_("cbEVT_BUILDTARGET_SELECTED"));
+                else if(type==cbEVT_PIPEDPROCESS_STDOUT) msg.Append(_("cbEVT_PIPEDPROCESS_STDOUT"));
+                else if(type==cbEVT_PIPEDPROCESS_STDERR) msg.Append(_("cbEVT_PIPEDPROCESS_STDERR"));
+                else if(type==cbEVT_PIPEDPROCESS_TERMINATED) msg.Append(_("cbEVT_PIPEDPROCESS_TERMINATED"));
+                else if(type==cbEVT_THREADTASK_STARTED) msg.Append(_("cbEVT_THREADTASK_STARTED"));
+                else if(type==cbEVT_THREADTASK_ENDED) msg.Append(_("cbEVT_THREADTASK_ENDED"));
+                else if(type==cbEVT_THREADTASK_ALLDONE) msg.Append(_("cbEVT_THREADTASK_ALLDONE"));
+                else if(type==cbEVT_MENUBAR_CREATE_BEGIN) msg.Append(_("cbEVT_MENUBAR_CREATE_BEGIN"));
+                else if(type==cbEVT_MENUBAR_CREATE_END) msg.Append(_("cbEVT_MENUBAR_CREATE_END"));
+                else if(type==cbEVT_COMPILER_STARTED) msg.Append(_("cbEVT_COMPILER_STARTED"));
+                else if(type==cbEVT_COMPILER_FINISHED) msg.Append(_("cbEVT_COMPILER_FINISHED"));
+                else if(type==cbEVT_COMPILER_SET_BUILD_OPTIONS) msg.Append(_("cbEVT_COMPILER_SET_BUILD_OPTIONS"));
+                else if(type==cbEVT_CLEAN_PROJECT_STARTED) msg.Append(_("cbEVT_CLEAN_PROJECT_STARTED"));
+                else if(type==cbEVT_CLEAN_WORKSPACE_STARTED) msg.Append(_("cbEVT_CLEAN_WORKSPACE_STARTED"));
+                else if(type==cbEVT_DEBUGGER_STARTED) msg.Append(_("cbEVT_DEBUGGER_STARTED"));
+                else if(type==cbEVT_DEBUGGER_STARTED) msg.Append(_("cbEVT_DEBUGGER_STARTED"));
+                else if(type==cbEVT_DEBUGGER_PAUSED) msg.Append(_("cbEVT_DEBUGGER_PAUSED"));
+                else if(type==cbEVT_DEBUGGER_FINISHED) msg.Append(_("cbEVT_DEBUGGER_FINISHED"));
+                else msg.Append(_("unknown CodeBlocksEvent"));
+
+                wxLogMessage(wxT("%s take %ld ms"), msg.wx_str(), sw.Time());
+
+            }
+        }
     }
     return true;
}
Index: src/main.cpp
===================================================================
--- src/main.cpp (revision 9090)
+++ src/main.cpp (working copy)
@@ -557,6 +557,7 @@
        m_pScriptConsole(0),
        m_pBatchBuildDialog(0)
{
+    wxLog::SetActiveTarget(new wxLogStderr());
     Manager::Get(this); // provide manager with handle to MainFrame (this)

     // register event sinks



See the test result below:
Quote
11:05:04: void (MainFrame::*)(CodeBlocksEvent&)cbEVT_PLUGIN_ATTACHED take 47 ms
11:05:04: void (MainFrame::*)(CodeBlocksEvent&)cbEVT_PLUGIN_ATTACHED take 31 ms
11:05:04: void (DebuggerManager::*)(CodeBlocksEvent&)cbEVT_PLUGIN_LOADING_COMPLETE take 31 ms
11:05:14: void (DebuggerManager::*)(CodeBlocksEvent&)cbEVT_PROJECT_ACTIVATE take 63 ms
11:05:15: void (CodeCompletion::*)(CodeBlocksEvent&)cbEVT_PROJECT_ACTIVATE take 359 ms
11:05:37: void (CodeCompletion::*)(cbEditor*, wxScintillaEvent&)wxEVT_SCI_CHARADDED take 47 ms
11:05:38: void (MainFrame::*)(CodeBlocksEvent&)cbEVT_EDITOR_UPDATE_UI take 16 ms
11:05:51: void (CodeCompletion::*)(cbEditor*, wxScintillaEvent&)wxEVT_SCI_CHARADDED take 32 ms
11:06:05: void (CodeCompletion::*)(cbEditor*, wxScintillaEvent&)wxEVT_SCI_AUTOCOMP_SELECTION take 32 ms
11:06:32: void (CodeCompletion::*)(cbEditor*, wxScintillaEvent&)wxEVT_SCI_CHARADDED take 78 ms
11:06:55: void (CodeCompletion::*)(cbEditor*, wxScintillaEvent&)wxEVT_SCI_CHARADDED take 31 ms
11:07:11: void (CodeCompletion::*)(cbEditor*, wxScintillaEvent&)wxEVT_SCI_CHARADDED take 31 ms
11:07:14: void (CodeCompletion::*)(cbEditor*, wxScintillaEvent&)wxEVT_SCI_CHARADDED take 31 ms


If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

xunxun

Maybe better to put the section to a #if-#define macro section such as CB_PROFILER
Regards,
xunxun