1 -- Created on: 2018-03-15
2 -- Created by: Stephan GARNAUD (ARM)
3 -- Copyright (c) 1998-1999 Matra Datavision
4 -- Copyright (c) 1999-2014 OPEN CASCADE SAS
6 -- This file is part of Open CASCADE Technology software library.
8 -- This library is free software; you can redistribute it and/or modify it under
9 -- the terms of the GNU Lesser General Public License version 2.1 as published
10 -- by the Free Software Foundation, with special exception defined in the file
11 -- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 -- distribution for complete text of the license and disclaimer of any warranty.
14 -- Alternatively, this file may be used under the terms of Open CASCADE
15 -- commercial license or contractual agreement.
17 -- Updated: J.P. TIRAULT August 1993
18 -- All methods are static methods.
19 -- the "Show" method returns the consumed CPU time in a Real
21 -- J.P. TIRAULT October 15 1994
22 -- We measure both user and system cpu time.
23 class Chronometer from OSD
25 ---Purpose: This class measures CPU time (both user and system) consumed
26 -- by current process or thread. The chronometer can be started
27 -- and stopped multiple times, and measures cumulative time.
29 -- If only the thread is measured, calls to Stop() and Show()
30 -- must occur from the same thread where Start() was called
31 -- (unless chronometer is stopped); otherwise measurement will
32 -- yield false values.
36 Create (ThisThreadOnly: Boolean = Standard_False) returns Chronometer from OSD;
37 ---Purpose: Initializes a stopped Chronometer.
39 -- If ThisThreadOnly is True, measured CPU time will account
40 -- time of the current thread only; otherwise CPU of the
41 -- process (all threads, and completed children) is measured.
45 ---C++ : alias " Standard_EXPORT virtual ~OSD_Chronometer();"
47 Reset (me : in out) is virtual;
48 ---Purpose: Stops and Reinitializes the Chronometer.
51 Stop (me : in out) is virtual;
52 ---Purpose: Stops the Chronometer.
55 Start (me : in out) is virtual;
56 ---Purpose: Starts (after Create or Reset) or restarts (after Stop)
61 ---Purpose: Shows the current CPU user and system time on the
62 -- standard output stream <cout>.
63 -- The chronometer can be running (laps Time) or stopped.
66 Show (me; os : in out OStream from Standard) is virtual;
67 ---Purpose: Shows the current CPU user and system time on the output
69 -- The chronometer can be running (laps Time) or stopped.
72 Show (me; theUserSeconds : in out Real from Standard);
73 ---Purpose: Returns the current CPU user time in a variable.
74 -- The chronometer can be running (laps Time) or stopped.
77 Show (me; theUserSeconds : in out Real from Standard;
78 theSystemSeconds : in out Real from Standard);
79 ---Purpose: Returns the current CPU user and system time in variables.
80 -- The chronometer can be running (laps Time) or stopped.
83 GetProcessCPU (myclass; UserSeconds : out Real from Standard;
84 SystemSeconds : out Real from Standard);
85 ---Purpose: Returns CPU time (user and system) consumed by the current
86 -- process since its start, in seconds. The actual precision of
87 -- the measurement depends on granularity provided by the system,
88 -- and is platform-specific.
91 GetThreadCPU (myclass; UserSeconds : out Real from Standard;
92 SystemSeconds : out Real from Standard);
93 ---Purpose: Returns CPU time (user and system) consumed by the current
94 -- thread since its start. Note that this measurement is
95 -- platform-specific, as threads are implemented and managed
96 -- differently on different platforms and CPUs.
101 Stopped : Boolean is protected;
102 ThreadOnly : Boolean;