vul_timer.h
Go to the documentation of this file.
1 // This is core/vul/vul_timer.h
2 //
3 // Copyright (C) 1991 Texas Instruments Incorporated.
4 //
5 // Permission is granted to any individual or institution to use, copy, modify,
6 // and distribute this software, provided that this complete copyright and
7 // permission notice is maintained, intact, in all copies and supporting
8 // documentation.
9 //
10 // Texas Instruments Incorporated provides this software "as is" without
11 // express or implied warranty.
12 #ifndef vul_timer_h
13 #define vul_timer_h
14 //:
15 // \file
16 // \brief A timing facility for C++
17 // \author This code was originally written by Joe Rahmeh at UT Austin.
18 //
19 // The vul_timer class provides an interface to system timing.
20 // It allows a C++ program to record the time between a reference
21 // point (mark) and now. This class uses the system
22 // time(2) interface to provide time resolution at either
23 // millisecond or microsecond granularity, depending upon
24 // operating system support and features. Since the time duration is
25 // stored in a 32-bit word, the maximum time period before
26 // rollover occurs is about 71 minutes.
27 //
28 // Due to operating system dependencies, the accuracy of all
29 // member function results may not be as documented. For example,
30 // some operating systems do not support timers with
31 // microsecond resolution. In those cases, the values returned
32 // are provided to the nearest millisecond or other unit of
33 // time as appropriate. See the Timer header file for system
34 // specific notes.
35 //
36 // The Timer class provides timing code for performance evaluation.
37 // - User time: time cpu spends in user mode on behalf of the program.
38 // - System time: time cpu spends in system mode on behalf of the program.
39 // - Real time: what you get from a stop watch timer.
40 //
41 // \verbatim
42 // Modifications
43 // Created: BMK 07/14/89 Initial design and implementation.
44 // Updated: LGO 09/23/89 Conform to COOL coding style.
45 // Updated: AFM 12/31/89 OS/2 port.
46 // Updated: DLS 03/22/91 New lite version.
47 // Updated: VDN 10/14/93 ANSI C does not have user/system time.
48 // Peter Vanroose 27/05/2001: Corrected the documentation
49 // \endverbatim
50 
51 //: struct containing timer data
52 struct vul_timer_data;
53 
54 #include <iosfwd>
55 #ifdef _MSC_VER
56 # include <vcl_msvc_warnings.h>
57 #endif
58 
59 //: The Timer class provides timing code for performance evaluation.
60 class vul_timer
61 {
62  //: struct containing timer data
64  public:
65  //: construct and reset counter to now.
66  vul_timer();
67  ~vul_timer();
68  //: Reset the counted to now
69  void mark();
70  //: Real time (ms) since last mark
71  long real();
72  //: User time (ms) since last mark
73  long user();
74  //: System time (ms) since last mark
75  long system();
76  //: User+system time (ms) since last mark
77  long all();
78 
79  //: Display user and real time since the last mark.
80  void print(std::ostream& s);
81 
82  private:
83  // disallow assigning to objects of this class:
84  vul_timer(vul_timer const &) { }
85  vul_timer& operator=(vul_timer const &) { return *this; }
86 };
87 
88 #endif // vul_timer_h
vul_timer()
construct and reset counter to now.
Definition: vul_timer.cxx:65
vul_timer_data * data
struct containing timer data.
Definition: vul_timer.h:63
long system()
System time (ms) since last mark.
Definition: vul_timer.cxx:151
vul_timer & operator=(vul_timer const &)
Definition: vul_timer.h:85
void print(std::ostream &s)
Display user and real time since the last mark.
Definition: vul_timer.cxx:179
long user()
User time (ms) since last mark.
Definition: vul_timer.cxx:137
vul_timer(vul_timer const &)
Definition: vul_timer.h:84
void mark()
Reset the counted to now.
Definition: vul_timer.cxx:79
long all()
User+system time (ms) since last mark.
Definition: vul_timer.cxx:165
The Timer class provides timing code for performance evaluation.
Definition: vul_timer.h:60
long real()
Real time (ms) since last mark.
Definition: vul_timer.cxx:102