00001 // This is core/vul/vul_timer.h 00002 // 00003 // Copyright (C) 1991 Texas Instruments Incorporated. 00004 // 00005 // Permission is granted to any individual or institution to use, copy, modify, 00006 // and distribute this software, provided that this complete copyright and 00007 // permission notice is maintained, intact, in all copies and supporting 00008 // documentation. 00009 // 00010 // Texas Instruments Incorporated provides this software "as is" without 00011 // express or implied warranty. 00012 #ifndef vul_timer_h 00013 #define vul_timer_h 00014 //: 00015 // \file 00016 // \brief A timing facility for C++ 00017 // \author This code was originally written by Joe Rahmeh at UT Austin. 00018 // 00019 // The vul_timer class provides an interface to system timing. 00020 // It allows a C++ program to record the time between a reference 00021 // point (mark) and now. This class uses the system 00022 // time(2) interface to provide time resolution at either 00023 // millisecond or microsecond granularity, depending upon 00024 // operating system support and features. Since the time duration is 00025 // stored in a 32-bit word, the maximum time period before 00026 // rollover occurs is about 71 minutes. 00027 // 00028 // Due to operating system dependencies, the accuracy of all 00029 // member function results may not be as documented. For example, 00030 // some operating systems do not support timers with 00031 // microsecond resolution. In those cases, the values returned 00032 // are provided to the nearest millisecond or other unit of 00033 // time as appropriate. See the Timer header file for system 00034 // specific notes. 00035 // 00036 // The Timer class provides timing code for performance evaluation. 00037 // - User time: time cpu spends in user mode on behalf of the program. 00038 // - System time: time cpu spends in system mode on behalf of the program. 00039 // - Real time: what you get from a stop watch timer. 00040 // 00041 // \verbatim 00042 // Modifications 00043 // Created: BMK 07/14/89 Initial design and implementation. 00044 // Updated: LGO 09/23/89 Conform to COOL coding style. 00045 // Updated: AFM 12/31/89 OS/2 port. 00046 // Updated: DLS 03/22/91 New lite version. 00047 // Updated: VDN 10/14/93 ANSI C does not have user/system time. 00048 // Peter Vanroose 27/05/2001: Corrected the documentation 00049 // \endverbatim 00050 00051 //: struct containing timer data 00052 struct vul_timer_data; 00053 00054 #include <vcl_iosfwd.h> 00055 00056 //: The Timer class provides timing code for performance evaluation. 00057 class vul_timer 00058 { 00059 //: struct containing timer data 00060 vul_timer_data *data; 00061 public: 00062 //: construct and reset counter to now. 00063 vul_timer(); 00064 ~vul_timer(); 00065 //: Reset the counted to now 00066 void mark(); 00067 //: Real time (ms) since last mark 00068 long real(); 00069 //: User time (ms) since last mark 00070 long user(); 00071 //: System time (ms) since last mark 00072 long system(); 00073 //: User+system time (ms) since last mark 00074 long all(); 00075 00076 //: Display user and real time since the last mark. 00077 void print(vcl_ostream& s); 00078 00079 private: 00080 // disallow assigning to objects of this class: 00081 vul_timer(vul_timer const &) { } 00082 vul_timer& operator=(vul_timer const &) { return *this; } 00083 }; 00084 00085 #endif // vul_timer_h