⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vmperftracking.h

📁 TOOL (Tiny Object Oriented Language) is an easily-embedded, object-oriented, C++-like-language inter
💻 H
字号:
#ifndef VM_PERFORMANCE_COUNTER_H_INCLUDED
#define VM_PERFORMANCE_COUNTER_H_INCLUDED
/*****************************************************************************/
/*                              HEADER FILE                                  */
/*****************************************************************************/
/*
          $Archive:   $

         $Revision:   $

      Last Checkin:
             $Date:   $
                By:
           $Author:   $

 Last Modification:
          $ModTime:   $

       Description:   Simple means of tracing the total number of calls to 
                      'any arbitrary key' and the total tick time spent in
                      each keyed arena

                      TOOL And XML FORMS License
                      ==========================

                      Except where otherwise noted, all of the documentation 
                      and software included in the TOOL package is 
                      copyrighted by Michael Swartzendruber.

                      Copyright (C) 2005 Michael John Swartzendruber. 
                      All rights reserved.

                      Access to this code, whether intentional or accidental,
                      does NOT IMPLY any transfer of rights.

                      This software is provided "as-is," without any express 
                      or implied warranty. In no event shall the author be held
                      liable for any damages arising from the use of this software.

                      Permission is granted to anyone to use this software for 
                      any purpose, including commercial applications, and to 
                      alter and redistribute it, provided that the following 
                      conditions are met:

                      1. All redistributions of source code files must retain 
                         all copyright notices that are currently in place, 
                         and this list of conditions without modification.

                      2. The origin of this software must not be misrepresented;
                         you must not claim that you wrote the original software.

                      3. If you use this software in another product, an acknowledgment
                         in the product documentation would be appreciated but is
                         not required.

                      4. Modified versions in source or binary form must be plainly 
                         marked as such, and must not be misrepresented as being 
                         the original software.
*/
/*****************************************************************************/


#include "../../../stdafx.h"
#include <map>


typedef struct _tagPerfData
{
  long             m_dwCalledCounter;
  LARGE_INTEGER    m_xTotalExecTime;
  CRITICAL_SECTION m_xCriticalSection;
} 
PERF_COUNTER_DATA, *P_PERF_COUNTER_DATA;



struct VMPerfKeyCompare
{
  bool operator()( const char* s1, const char* s2 ) const
  {
    return strcmp( s1, s2 ) < 0;
  }
};

class VMPerfStats
{
public:
  static VMPerfStats* GetInstance( void );

  P_PERF_COUNTER_DATA GetCounter( const char* pchName );

  ~VMPerfStats( void );

  void DumpAllStats( void );

private:
  typedef std::map< const char*, P_PERF_COUNTER_DATA, VMPerfKeyCompare > COUNTER_MAP;
  typedef COUNTER_MAP::iterator                                          COUNTER_MAP_ITER;

  COUNTER_MAP      m_oCounters;
  CRITICAL_SECTION m_xCriticalSection;

  VMPerfStats( void );
  VMPerfStats( const VMPerfStats& roOther ){;};
  VMPerfStats& operator= ( const VMPerfStats& roOther ){;};
};


class VMPerfTimer
{
public:
  VMPerfTimer( const char* pchKey, bool bAutoStart = true );
  ~VMPerfTimer( void );

  void StartTimer( void );
  void StopTimer( void );

private:
  P_PERF_COUNTER_DATA  m_pxPerfData;
  LARGE_INTEGER        m_xEnterTime;
  bool                 m_bTimerRunning;
};


#endif


/*****************************************************************************/
/* Check-in history 
   $WorkFile:   $
    $Archive:   $

 *$Log:   $
*/
/*****************************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -