Code::Blocks  SVN r11506
profiletimer.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3
3  * http://www.gnu.org/licenses/gpl-3.0.html
4  *
5  * $Revision: 7749 $
6  * $Id: profiletimer.cpp 7749 2012-02-01 09:42:05Z mortenmacfly $
7  * $HeadURL: https://svn.code.sf.net/p/codeblocks/code/trunk/src/plugins/codecompletion/parser/profiletimer.cpp $
8  */
9 
10 #include "profiletimer.h"
11 
12 #include "manager.h"
13 #include "logmanager.h"
14 
16 
17 ProfileTimerData::ProfileTimerData() : m_CallTimes(0), m_Count(0)
18 {
20 }
21 
23 {
26  m_CallTimes = 0;
27  m_Count = 0;
28 }
29 
31  m_ProfileTimerData(profileTimerData)
32 {
33  if (m_ProfileTimerData.m_Count++ == 0)
35 }
36 
38 {
39  if (--m_ProfileTimerData.m_Count == 0)
41 }
42 
43 /* static */ size_t ProfileTimer::Registry(ProfileTimerData* ptd, const wxString& funcName)
44 {
45  m_ProfileMap[ptd] = funcName;
46  return 1;
47 }
48 
49 /* static */ void ProfileTimer::Log()
50 {
51  for (ProfileMap::iterator it = m_ProfileMap.begin(); it != m_ProfileMap.end(); ++it)
52  {
53  const long totalTime = it->first->m_StopWatch.Time();
54  wxString log;
55  log.Printf(_T("\"%s\" used time is %ld minute(s), %ld.%03ld seconds; call times is %lu."),
56  it->second.wx_str(),
57  (totalTime / 60000),
58  (totalTime / 1000) % 60,
59  (totalTime % 1000),
60  static_cast<unsigned long>(it->first->m_CallTimes));
61 #ifndef CC_PARSER_TEST
63 #endif
64  it->first->Zero();
65  }
66 }
static size_t Registry(ProfileTimerData *ptd, const wxString &funcName)
static Manager * Get()
Use Manager::Get() to get a pointer to its instance Manager::Get() is guaranteed to never return an i...
Definition: manager.cpp:182
ProfileTimerHelper(ProfileTimerData &profileTimerData)
ProfileTimerData & m_ProfileTimerData
Definition: profiletimer.h:47
#define _T(string)
std::map< ProfileTimerData *, wxString > ProfileMap
Definition: profiletimer.h:57
wxStopWatch m_StopWatch
Definition: profiletimer.h:36
void Pause()
LogManager * GetLogManager() const
Definition: manager.cpp:439
void Resume()
void Start(long milliseconds=0)
void DebugLog(const wxString &msg, Logger::level lv=Logger::info)
Definition: logmanager.h:146
static void Log()
int Printf(const wxString &pszFormat,...)
static ProfileMap m_ProfileMap
Definition: profiletimer.h:58