ʻOhana
Population structure, admixture history, and selection using learning methods.
Public Types | Public Member Functions
jade::basic_stopwatch< TClock > Class Template Reference

A template class imlementing a stopwatch. More...

#include <jade.stopwatch.hpp>

+ Inheritance diagram for jade::basic_stopwatch< TClock >:
+ Collaboration diagram for jade::basic_stopwatch< TClock >:

Public Types

typedef TClock clock_type
 The clock type. More...
 
typedef clock_type::time_point time_point_type
 The time point type for the clock. More...
 

Public Member Functions

 basic_stopwatch ()
 Initializes a new instance of the class. More...
 
int compare (const double seconds) const
 Compares the elapsed time with the specified number of seconds. The method returns a negative value if the elapsed time is lesser. More...
 
double get_elapsed () const
 
std::string str () const
 
bool operator< (const double rhs) const
 Compares the elapsed time with the specified number of seconds. The operator returns a negative value if the elapsed time is lesser. More...
 
bool operator> (const double rhs) const
 Compares the elapsed time with the specified number of seconds. The operator returns a negative value if the elapsed time is greater. More...
 

Detailed Description

template<typename TClock>
class jade::basic_stopwatch< TClock >

A template class imlementing a stopwatch.

Definition at line 18 of file jade.stopwatch.hpp.

Member Typedef Documentation

◆ clock_type

template<typename TClock >
typedef TClock jade::basic_stopwatch< TClock >::clock_type

The clock type.

Definition at line 22 of file jade.stopwatch.hpp.

◆ time_point_type

template<typename TClock >
typedef clock_type::time_point jade::basic_stopwatch< TClock >::time_point_type

The time point type for the clock.

Definition at line 25 of file jade.stopwatch.hpp.

Constructor & Destructor Documentation

◆ basic_stopwatch()

template<typename TClock >
jade::basic_stopwatch< TClock >::basic_stopwatch ( )
inline

Initializes a new instance of the class.

Definition at line 30 of file jade.stopwatch.hpp.

31  : _t0 (clock_type::now())
32  {
33  }

Member Function Documentation

◆ compare()

template<typename TClock >
int jade::basic_stopwatch< TClock >::compare ( const double  seconds) const
inline

Compares the elapsed time with the specified number of seconds. The method returns a negative value if the elapsed time is lesser.

Returns
Negative, positive, or zero.
Parameters
secondsThe elapsed seconds to compare.

Definition at line 41 of file jade.stopwatch.hpp.

44  {
45  const auto lhs = get_elapsed();
46  const auto rhs = seconds;
47  return lhs < rhs ? -1 : rhs < lhs ? +1 : 0;
48  }
+ Here is the caller graph for this function:

◆ get_elapsed()

template<typename TClock >
double jade::basic_stopwatch< TClock >::get_elapsed ( ) const
inline
Returns
The elapsed time in seconds as a floating-point value.

Definition at line 53 of file jade.stopwatch.hpp.

54  {
55  const auto t1 = clock_type::now();
56  const auto dt = std::chrono::duration<double>(t1 - _t0);
57  return dt.count();
58  }
+ Here is the caller graph for this function:

◆ operator<()

template<typename TClock >
bool jade::basic_stopwatch< TClock >::operator< ( const double  rhs) const
inline

Compares the elapsed time with the specified number of seconds. The operator returns a negative value if the elapsed time is lesser.

Returns
True if the value is lesser; otherwise false.
Parameters
rhsThe elapsed seconds to compare.

Definition at line 76 of file jade.stopwatch.hpp.

79  {
80  return compare(rhs) < 0;
81  }

◆ operator>()

template<typename TClock >
bool jade::basic_stopwatch< TClock >::operator> ( const double  rhs) const
inline

Compares the elapsed time with the specified number of seconds. The operator returns a negative value if the elapsed time is greater.

Returns
True if the value is greater; otherwise false.
Parameters
rhsThe elapsed seconds to compare.

Definition at line 89 of file jade.stopwatch.hpp.

92  {
93  return compare(rhs) > 0;
94  }

◆ str()

template<typename TClock >
std::string jade::basic_stopwatch< TClock >::str ( ) const
inline
Returns
The current time as a string.

Definition at line 63 of file jade.stopwatch.hpp.

64  {
65  std::ostringstream out;
66  out << std::fixed << std::setprecision(6) << get_elapsed();
67  return out.str();
68  }

The documentation for this class was generated from the following file:
jade::basic_stopwatch::get_elapsed
double get_elapsed() const
Definition: jade.stopwatch.hpp:53
jade::basic_stopwatch::compare
int compare(const double seconds) const
Compares the elapsed time with the specified number of seconds. The method returns a negative value i...
Definition: jade.stopwatch.hpp:41