From: <ma...@us...> - 2003-12-30 11:34:35
|
Update of /cvsroot/sharedaemon/ui-wx/src In directory sc8-pr-cvs1:/tmp/cvs-serv14712 Modified Files: GUISettingsDlg.cpp Images.cpp MainDlg.cpp defines.h Log Message: Debugging macro to measure time spent in functions. Index: GUISettingsDlg.cpp =================================================================== RCS file: /cvsroot/sharedaemon/ui-wx/src/GUISettingsDlg.cpp,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- GUISettingsDlg.cpp 29 Dec 2003 08:50:50 -0000 1.34 +++ GUISettingsDlg.cpp 30 Dec 2003 11:34:31 -0000 1.35 @@ -78,6 +78,7 @@ * Loads settings from config object and sets up dialog controls values. */ void CGUISettingsDlg::LoadSettings() { +TIMER_START(wxT("CGUISettingsDlg::LoadSettings")); int font, iconset, tool_align, numlang, numiconsets; bool show_splash, prompt_exit, show_toolbar, show_menubar, remember_last; @@ -165,12 +166,14 @@ if (GetRememberLast()->GetValue()) { GetStartPage()->Disable(); } +TIMER_STOP(); } /* * Writes control values to config object. */ void CGUISettingsDlg::SaveSettings() { +TIMER_START(wxT("CGUISettingsDlg::SaveSettings")); int old_tool_align, tool_align, i; wxString old_icon_set, icon_set; bool old_show_tool, show_tool; @@ -267,6 +270,7 @@ if (old_icon_set != icon_set) { mainframe->UpdateImages(); } +TIMER_STOP(); } /* Index: Images.cpp =================================================================== RCS file: /cvsroot/sharedaemon/ui-wx/src/Images.cpp,v retrieving revision 1.49 retrieving revision 1.50 diff -u -d -r1.49 -r1.50 --- Images.cpp 29 Dec 2003 09:12:33 -0000 1.49 +++ Images.cpp 30 Dec 2003 11:34:31 -0000 1.50 @@ -59,6 +59,7 @@ /* TODO: Put names into temporary wxString array and use for-loop to load 'em.*/ /******************************************************************************/ void CImages::LoadImages() { +TIMER_START(wxT("CImages::LoadImages")); wxString path; tool_img_width = 32; @@ -247,6 +248,7 @@ wxT("quit"), new wxBitmap(path+wxT("quit.png"), wxBITMAP_TYPE_ANY) ); +TIMER_STOP(); } /******************************************************************* GetImage */ Index: MainDlg.cpp =================================================================== RCS file: /cvsroot/sharedaemon/ui-wx/src/MainDlg.cpp,v retrieving revision 1.55 retrieving revision 1.56 diff -u -d -r1.55 -r1.56 --- MainDlg.cpp 30 Dec 2003 10:28:39 -0000 1.55 +++ MainDlg.cpp 30 Dec 2003 11:34:31 -0000 1.56 @@ -304,6 +304,7 @@ /* @gen_images If true, also (re)generates images */ /******************************************************************************/ void CMainDlg::CreateMyToolBar(bool gen_images) { +TIMER_START(wxT("CMainDlg::CreateMyToolBar")); int tool_align; /* For storing values read from configuration */ bool show_tool; /* For storing values read from configuration */ unsigned int i; /* Loop counter */ @@ -355,6 +356,7 @@ tb->Refresh(); /* Fix for wxMac issues */ Layout(); /* Needed after deleting/creation */ UpdateToolBar(); +TIMER_STOP(); } /***************************************************** GenerateToolBarButtons */ @@ -369,6 +371,7 @@ void CMainDlg::GenerateToolBarButtons( MyToolBar *tb, bool gen_images, int tool_align ) { +TIMER_START(wxT("CMainDlg::GenerateToolBarButtons")); wxArrayString names, images; /* Names/images for multibuttons */ int ids[2]; /* Identifiers for multibutton controls */ unsigned int i; /* Loop counter */ @@ -489,6 +492,7 @@ wxT("Change GUI Settings") ); #endif +TIMER_STOP(); } /************************************************************** OnCloseWindow */ @@ -1183,19 +1187,13 @@ /* through the list of pages and calling images->UpdateImages on each of them.*/ /******************************************************************************/ void CMainDlg::UpdateImages() { +TIMER_START(wxT("CMainDlg::UpdateImages")); img->LoadImages(); wxLogDebug(wxT("Updating all pages images...")); for (size_t i=0;i<pages.GetCount();i++) { if (pages.IsEmpty()) { break; } - wxLogDebug( - wxT("Count = %d Current = %d"), pages.GetCount(), i - ); - wxLogDebug( - wxT("Updating `%s` page images."), - pages[i]->short_title.c_str() - ); img->UpdateImages(pages[i]->content); } CreateMyToolBar(true); @@ -1208,5 +1206,5 @@ #if defined(wxHAS_TASK_BAR_ICON) && defined(__WXMSW__) systray->SetIcon(icon); #endif - +TIMER_STOP(); } Index: defines.h =================================================================== RCS file: /cvsroot/sharedaemon/ui-wx/src/defines.h,v retrieving revision 1.44 retrieving revision 1.45 diff -u -d -r1.44 -r1.45 --- defines.h 22 Dec 2003 05:04:15 -0000 1.44 +++ defines.h 30 Dec 2003 11:34:31 -0000 1.45 @@ -56,6 +56,23 @@ #define border_style 0 #endif +/** + * Some debugging macros for measuring time spent in function(s). Call + * TIMER_START with function name (wxString) to start the timer, and then + * TIMER_STOP to reset the timer and print out elapsed time. + */ +#ifdef __WXDEBUG__ + #define TIMER_START(func) wxStartTimer(); wxString cur_func=func + #define TIMER_STOP() \ + wxLogDebug( \ + wxT("Time spent in `%s`: %dms"), \ + cur_func.c_str(), wxGetElapsedTime() \ + ) +#else + #define TIMER_START(func) + #define TIMER_STOP() +#endif + extern class CServerWnd *serverwnd; extern class CSearchWnd *searchwnd; extern class CTransferWnd *transferwnd; |