summaryrefslogtreecommitdiff
path: root/examples/Threads/Timer.h
blob: 353fc54698ae5f53eee8e87d90ae53e32b0e50f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/* -*- C++ -*- */
// $Id$

// ============================================================================
//
// = LIBRARY
//    (none)
//
// = FILENAME
//    Timer.h
//
// = DESCRIPTION
//    Adapter to platform-specific timer class.  The "default interface"
//    is that of ACE_High_Res_Timer.  Clients should use its member functions,
//    but declare instances of type Timer instead of ACE_High_Res_Timer.
//
// = AUTHOR
//    David L. Levine
//
// ============================================================================

#if ! defined (TIMER_H)
#define TIMER_H

#if defined (__sun)
#include <ace/High_Res_Timer.h>

typedef ACE_High_Res_Timer Timer;


#if 0
#elif defined (VXWORKS)
// NOTE:  ppctimer.h isn't distributed with ACE.  It is based on
// an assembly language routing for reading the clock that is
// available in the Motorola documentation for the PowerPC.

#include <ppctimer.h>

class Timer : public PPCTimer
{
public:
  Timer () : PPCTimer () {}
  ~Timer () {}    // WARNING:  non-virtual, assumes that base class destructor
                  // doesn't do anything significant

  void print_ave (const char *message,
		  const int /* iterations */ = 1,
		  ACE_HANDLE /* handle */ = ACE_STDOUT)
    {
      printTimerStats (message);
    }

  unsigned long get_time () const { return getTime (); }

private:
  // the following functions are not implemented . . .
  Timer (const Timer &);
  Timer &operator= (const Timer &);
};
#endif // 0

#else
// dummy class so that the test will build, but it won't provide
// timings

class Timer
{
public:
  Timer () {}
  ~Timer () {}

  void print_ave (const char *message,
		  const int /* iterations */ = 1,
                  ACE_HANDLE /* handle */ = ACE_STDOUT) {}

  unsigned long get_time () const { return -1; }

private:
  // the following functions are not implemented . . .
  Timer (const Timer &);
  Timer &operator= (const Timer &);
};
#endif

#endif /* TIMER_H */


/* EOF */