Skip to content
nphtan edited this page May 19, 2021 · 2 revisions

Kokkos::Resilience::Util::Timer

Simple timer abstraction.

Header File: Timer.hpp

Synopsis

class Timer
  {
  public:
    
    using clock_type = std::chrono::high_resolution_clock;
    using duration_type = clock_type::duration;
    using time_type = std::chrono::time_point< clock_type >;
    
    explicit Timer( bool start_timer = false )
    {
      if ( start_timer )
        start();
    }
  
    void start() noexcept { m_start = clock_type::now(); }
    duration_type time() const noexcept { return clock_type::now() - m_start; }
    
  private:
    
    time_type m_start;
  };

Public Class Members

Typedefs

  • clock_type: The type of clock.
  • duration_type: The time duration type.
  • time_type: The type of the time point.

Constructor

  • explicit Timer( bool start_timer = false )
    Construct timer objection. Optionally tell timer to start on creation.

Functions

  • void start() noexcept

    Start timer.

  • duration_type time() const noexcept

    Get the timers current elapsed time.