File: OSD_Chronometer.hxx

package info (click to toggle)
oce 0.18.3-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 301,548 kB
  • sloc: cpp: 1,190,609; ansic: 67,225; sh: 11,630; tcl: 7,954; cs: 5,221; python: 2,867; java: 1,522; makefile: 342; xml: 292; perl: 37
file content (110 lines) | stat: -rw-r--r-- 3,453 bytes parent folder | download | duplicates (3)
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// This file is generated by WOK (CPPExt).
// Please do not edit this file; modify original file instead.
// The copyright and license terms as defined for the original file apply to 
// this header file considered to be the "object code" form of the original source.

#ifndef _OSD_Chronometer_HeaderFile
#define _OSD_Chronometer_HeaderFile

#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Macro.hxx>

#include <Standard_Boolean.hxx>
#include <Standard_Real.hxx>
#include <Standard_OStream.hxx>


//! This class measures CPU time (both user and system) consumed
//! by current process or thread. The chronometer can be started
//! and stopped multiple times, and measures cumulative time.
//!
//! If only the thread is measured, calls to Stop() and Show()
//! must occur from the same thread where Start() was called
//! (unless chronometer is stopped); otherwise measurement will
//! yield false values.
class OSD_Chronometer 
{
public:

  DEFINE_STANDARD_ALLOC

  
  //! Initializes a stopped Chronometer.
  //!
  //! If ThisThreadOnly is True, measured CPU time will account
  //! time of the current thread only; otherwise CPU of the
  //! process (all threads, and completed children) is measured.
  Standard_EXPORT OSD_Chronometer(const Standard_Boolean ThisThreadOnly = Standard_False);
  Standard_EXPORT virtual ~OSD_Chronometer();
  
  //! Stops and Reinitializes the Chronometer.
  Standard_EXPORT virtual   void Reset() ;
  
  //! Stops the Chronometer.
  Standard_EXPORT virtual   void Stop() ;
  
  //! Starts (after Create or Reset) or restarts (after Stop)
  //! the chronometer.
  Standard_EXPORT virtual   void Start() ;
  
  //! Shows the current CPU user and system time on the
  //! standard output stream <cout>.
  //! The chronometer can be running (laps Time) or stopped.
  Standard_EXPORT virtual   void Show()  const;
  
  //! Shows the current CPU user and system time on the output
  //! stream <os>.
  //! The chronometer can be running (laps Time) or stopped.
  Standard_EXPORT virtual   void Show (Standard_OStream& os)  const;
  
  //! Returns the current CPU user time in a variable.
  //! The chronometer can be running (laps Time) or stopped.
  Standard_EXPORT   void Show (Standard_Real& theUserSeconds)  const;
  
  //! Returns the current CPU user and system time in variables.
  //! The chronometer can be running (laps Time) or stopped.
  Standard_EXPORT   void Show (Standard_Real& theUserSeconds, Standard_Real& theSystemSeconds)  const;
  
  //! Returns CPU time (user and system) consumed by the current
  //! process since its start, in seconds. The actual precision of
  //! the measurement depends on granularity provided by the system,
  //! and is platform-specific.
  Standard_EXPORT static   void GetProcessCPU (Standard_Real& UserSeconds, Standard_Real& SystemSeconds) ;
  
  //! Returns CPU time (user and system) consumed by the current
  //! thread since its start. Note that this measurement is
  //! platform-specific, as threads are implemented and managed
  //! differently on different platforms and CPUs.
  Standard_EXPORT static   void GetThreadCPU (Standard_Real& UserSeconds, Standard_Real& SystemSeconds) ;




protected:



  Standard_Boolean Stopped;


private:



  Standard_Boolean ThreadOnly;
  Standard_Real Start_user;
  Standard_Real Start_sys;
  Standard_Real Cumul_user;
  Standard_Real Cumul_sys;


};







#endif // _OSD_Chronometer_HeaderFile