SheafSystem  0.0.0.0
sheaf::stop_watch Class Reference

A clock for timing intervals. More...

#include <stop_watch.h>

Public Types

enum  time_unit { CPU_TIME, MILLISECONDS, SECONDS }
 The unit of time to return. More...
 

Public Member Functions

virtual bool invariant () const
 Class invariant. More...
 
 stop_watch ()
 Default constructor. More...
 
virtual ~stop_watch ()
 Destructor. More...
 
void start ()
 Marks the start of an interval. More...
 
void stop ()
 Marks the end of an interval. More...
 
double time (time_unit xunit=SECONDS) const
 The length of the current interval. More...
 
double cumulative_time () const
 The accumulated time in seconds between start()'s and stop()'s since the last reset(). More...
 
void mark_lap ()
 Marks the end of the current lap. More...
 
double lap_time (int i) const
 The length in seconds of the xi-th lap. More...
 
size_t lap_ct () const
 The number of laps that have be marked. More...
 
void reset ()
 Clears the lap times and sets lap_ct() to 0. More...
 

Detailed Description

A clock for timing intervals.

Definition at line 45 of file stop_watch.h.

Member Enumeration Documentation

◆ time_unit

The unit of time to return.

Definition at line 82 of file stop_watch.h.

Constructor & Destructor Documentation

◆ stop_watch()

sheaf::stop_watch::stop_watch ( )

Default constructor.

Postcondition

Definition at line 49 of file stop_watch.cc.

References invariant(), reset(), and ~stop_watch().

Referenced by invariant().

◆ ~stop_watch()

sheaf::stop_watch::~stop_watch ( )
virtual

Destructor.

Definition at line 68 of file stop_watch.cc.

References start().

Referenced by stop_watch().

Member Function Documentation

◆ cumulative_time()

double sheaf::stop_watch::cumulative_time ( ) const

The accumulated time in seconds between start()'s and stop()'s since the last reset().

Definition at line 157 of file stop_watch.cc.

References mark_lap().

Referenced by sheaf::operator<<(), and time().

◆ invariant()

bool sheaf::stop_watch::invariant ( ) const
virtual

Class invariant.

Invariant
  • _start_time <= _stop_time

Definition at line 33 of file stop_watch.cc.

References stop_watch().

Referenced by stop_watch().

◆ lap_ct()

size_t sheaf::stop_watch::lap_ct ( ) const

The number of laps that have be marked.

Definition at line 221 of file stop_watch.cc.

References reset().

Referenced by lap_time(), sheaf::operator<<(), and reset().

◆ lap_time()

double sheaf::stop_watch::lap_time ( int  i) const

The length in seconds of the xi-th lap.

Precondition

Definition at line 197 of file stop_watch.cc.

References lap_ct().

Referenced by mark_lap(), and sheaf::operator<<().

◆ mark_lap()

void sheaf::stop_watch::mark_lap ( )

Marks the end of the current lap.

Definition at line 176 of file stop_watch.cc.

References lap_time(), stop(), and time().

Referenced by cumulative_time().

◆ reset()

void sheaf::stop_watch::reset ( )

Clears the lap times and sets lap_ct() to 0.

Postcondition

Definition at line 242 of file stop_watch.cc.

References lap_ct(), and time().

Referenced by lap_ct(), and stop_watch().

◆ start()

void sheaf::stop_watch::start ( )

Marks the start of an interval.

Definition at line 85 of file stop_watch.cc.

References stop().

Referenced by ~stop_watch().

◆ stop()

void sheaf::stop_watch::stop ( )

Marks the end of an interval.

Definition at line 102 of file stop_watch.cc.

References time().

Referenced by mark_lap(), and start().

◆ time()

double sheaf::stop_watch::time ( time_unit  xunit = SECONDS) const

The length of the current interval.

Definition at line 121 of file stop_watch.cc.

References cumulative_time().

Referenced by mark_lap(), reset(), and stop().


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