libjmmcg  release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
p5 ticker.h
Go to the documentation of this file.
1 // Copyright © 1997-2002 by J.M.McGuiness, all rights reserved.
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 /////////////////////////////////////////////////////////////////////////////
18 
19 namespace jmmcg {
20 
21 typedef enum {
23 } P5_Ticker_Errors_Type;
24 
25 /**
26  This file declares a class the wraps the Pentium-specific time stamp counter. This counter has a resolution in terms of PCLKS (processor clocks) so it can be used for direct instruction timings.
27 */
28 class P5_Ticker : public CObject
29 {
31 
32 public:
33  P5_Ticker(void);
34  inline P5_Ticker(const P5_Ticker &);
35  inline ~P5_Ticker(void) {};
38  inline P5_Ticker operator+(const P5_Ticker &) const;
39  inline P5_Ticker operator-(const P5_Ticker &) const;
40  inline double To_Ticks(void) const {register LARGE_INTEGER tmp;tmp.QuadPart=count.QuadPart;return (double)tmp.QuadPart;};
41  P5_Ticker &Get_Time(void);
42  double Get_Frequency(double &,const unsigned long =1000,const unsigned int =20) const;
43  inline bool P5_Ticker_Available(void) const {return (Has_RDTSC);};
44 
45 #ifdef _DEBUG
46  virtual void AssertValid(void) const;
47  virtual void Dump(CDumpContext& dc) const;
48 #endif
49 
50 private:
51  typedef enum
52  {
53  win_nt,
54  win_95,
55  other
56  } os_type;
57  os_type on_os;
58  bool Has_RDTSC;
59  ULARGE_INTEGER count; // unsigned 64-bit integer. (MFC data type.)
60 
61  inline bool Check_Has_RDTSC(void) const;
62  inline os_type Check_Os(void) const;
63  inline P5_Ticker &Get_Time_NT(void);
64  inline P5_Ticker &Get_Time_95(void);
65 };
66 
67 }