OCCT 8.0.1
OCCT documentation

Search guides and API reference

Enter at least two characters.

    Open CASCADE Technology Reference Manual 8.0.1
    OSD_Timer Class Reference

    Working on heterogeneous platforms we need to use the system call gettimeofday. This function is portable and it measures ELAPSED time and CPU time in seconds and microseconds. Example: OSD_Timer aTimer; aTimer.Start(); // Start the timers (t1). ..... // Do something. aTimer.Stop(); // Stop the timers (t2). aTimer.Show(); // Give the elapsed time between t1 and t2. // Give also the process CPU time between // t1 and t2. More...

    #include <OSD_Timer.hxx>

    Inheritance diagram for OSD_Timer:

    Public Member Functions

     OSD_Timer (bool theThisThreadOnly=false)
     Builds a Chronometer initialized and stopped.
    void Reset (const double theTimeElapsedSec)
     Stops and reinitializes the timer with specified elapsed time.
    void Reset () override
     Stops and reinitializes the timer with zero elapsed time.
    void Restart () override
     Restarts the Timer.
    void Show () const override
     Shows both the elapsed time and CPU time on the standard output stream <cout>.The chronometer can be running (Lap Time) or stopped.
    void Show (Standard_OStream &os) const override
     Shows both the elapsed time and CPU time on the output stream <OS>.
    void Show (double &theSeconds, int &theMinutes, int &theHours, double &theCPUtime) const
     returns both the elapsed time(seconds,minutes,hours) and CPU time.
    void Stop () override
     Stops the Timer.
    void Start () override
     Starts (after Create or Reset) or restarts (after Stop) the Timer.
    double ElapsedTime () const
     Returns elapsed time in seconds.
    Public Member Functions inherited from OSD_Chronometer
     OSD_Chronometer (bool theThisThreadOnly=false)
     Initializes a stopped Chronometer.
    virtual ~OSD_Chronometer ()
     Destructor.
    bool IsStarted () const
     Return true if timer has been started.
    double UserTimeCPU () const
     Returns the current CPU user time in seconds. The chronometer can be running (laps Time) or stopped.
    double SystemTimeCPU () const
     Returns the current CPU system time in seconds. The chronometer can be running (laps Time) or stopped.
    bool IsThisThreadOnly () const
     Return TRUE if current thread CPU time should be measured, and FALSE to measure all threads CPU time; FALSE by default,.
    void SetThisThreadOnly (bool theIsThreadOnly)
     Set if current thread (TRUE) or all threads (FALSE) CPU time should be measured. Will raise exception if Timer is in started state.
    void Show (double &theUserSeconds) const
     Returns the current CPU user time in a variable. The chronometer can be running (laps Time) or stopped.
    void Show (double &theUserSec, double &theSystemSec) const
     Returns the current CPU user and system time in variables. The chronometer can be running (laps Time) or stopped.

    Static Public Member Functions

    static double GetWallClockTime ()
     Returns current time in seconds with system-defined precision. The could be a system uptime or a time from some date. Returned value is intended for precise elapsed time measurements as a delta between timestamps. On Windows implemented via QueryPerformanceCounter(), on other systems via gettimeofday().
    Static Public Member Functions inherited from OSD_Chronometer
    static void GetProcessCPU (double &UserSeconds, double &SystemSeconds)
     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.
    static void GetThreadCPU (double &UserSeconds, double &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.

    Additional Inherited Members

    Protected Attributes inherited from OSD_Chronometer
    double myStartCpuUser
    double myStartCpuSys
    double myCumulCpuUser
    double myCumulCpuSys
    bool myIsStopped
    bool myIsThreadOnly

    Detailed Description

    Working on heterogeneous platforms we need to use the system call gettimeofday. This function is portable and it measures ELAPSED time and CPU time in seconds and microseconds. Example: OSD_Timer aTimer; aTimer.Start(); // Start the timers (t1). ..... // Do something. aTimer.Stop(); // Stop the timers (t2). aTimer.Show(); // Give the elapsed time between t1 and t2. // Give also the process CPU time between // t1 and t2.

    Constructor & Destructor Documentation

    ◆ OSD_Timer()

    OSD_Timer::OSD_Timer ( bool theThisThreadOnly = false)

    Builds a Chronometer initialized and stopped.

    Parameters
    theThisThreadOnlywhen TRUE, measured CPU time will account time of the current thread only; otherwise CPU of the process (all threads, and completed children) is measured; this flag does NOT affect ElapsedTime() value, only values returned by OSD_Chronometer

    Member Function Documentation

    ◆ ElapsedTime()

    double OSD_Timer::ElapsedTime ( ) const

    Returns elapsed time in seconds.

    ◆ GetWallClockTime()

    double OSD_Timer::GetWallClockTime ( )
    static

    Returns current time in seconds with system-defined precision. The could be a system uptime or a time from some date. Returned value is intended for precise elapsed time measurements as a delta between timestamps. On Windows implemented via QueryPerformanceCounter(), on other systems via gettimeofday().

    ◆ Reset() [1/2]

    void OSD_Timer::Reset ( )
    overridevirtual

    Stops and reinitializes the timer with zero elapsed time.

    Reimplemented from OSD_Chronometer.

    ◆ Reset() [2/2]

    void OSD_Timer::Reset ( const double theTimeElapsedSec)

    Stops and reinitializes the timer with specified elapsed time.

    ◆ Restart()

    void OSD_Timer::Restart ( )
    overridevirtual

    Restarts the Timer.

    Reimplemented from OSD_Chronometer.

    ◆ Show() [1/3]

    void OSD_Timer::Show ( ) const
    overridevirtual

    Shows both the elapsed time and CPU time on the standard output stream <cout>.The chronometer can be running (Lap Time) or stopped.

    Reimplemented from OSD_Chronometer.

    ◆ Show() [2/3]

    void OSD_Timer::Show ( double & theSeconds,
    int & theMinutes,
    int & theHours,
    double & theCPUtime ) const

    returns both the elapsed time(seconds,minutes,hours) and CPU time.

    ◆ Show() [3/3]

    void OSD_Timer::Show ( Standard_OStream & os) const
    overridevirtual

    Shows both the elapsed time and CPU time on the output stream <OS>.

    Reimplemented from OSD_Chronometer.

    ◆ Start()

    void OSD_Timer::Start ( )
    overridevirtual

    Starts (after Create or Reset) or restarts (after Stop) the Timer.

    Reimplemented from OSD_Chronometer.

    ◆ Stop()

    void OSD_Timer::Stop ( )
    overridevirtual

    Stops the Timer.

    Reimplemented from OSD_Chronometer.


    The documentation for this class was generated from the following file: