LCOV - code coverage report
Current view: top level - Src/Utils - SpTimePoint.hpp (source / functions) Hit Total Coverage
Test: Coverage example Lines: 7 7 100.0 %
Date: 2021-12-02 17:21:05 Functions: 3 3 100.0 %

          Line data    Source code
       1             : ///////////////////////////////////////////////////////////////////////////
       2             : // Spetabaru - Berenger Bramas MPCDF - 2017
       3             : // Under LGPL Licence, please you must read the LICENCE file.
       4             : ///////////////////////////////////////////////////////////////////////////
       5             : #ifndef SPTIMEPOINT_HPP
       6             : #define SPTIMEPOINT_HPP
       7             : 
       8             : #include <chrono>
       9             : #include <cmath>
      10             : 
      11             : class SpTimePoint {
      12             :     std::chrono::high_resolution_clock::time_point timePoint;
      13             : 
      14             : public:
      15        4344 :     SpTimePoint() : timePoint(std::chrono::high_resolution_clock::now()) {}
      16             : 
      17        3219 :     void setToNow(){
      18        3219 :         timePoint = std::chrono::high_resolution_clock::now();
      19        3218 :     }
      20             : 
      21        6037 :     double differenceWith(const SpTimePoint& inOther) const{
      22             :         using double_second_time = std::chrono::duration<double, std::ratio<1, 1>>;
      23        6037 :         return std::abs(std::chrono::duration_cast<double_second_time>(
      24       12074 :                     std::chrono::duration_cast<std::chrono::nanoseconds>(timePoint - inOther.timePoint)).count());
      25             :     }
      26             : };
      27             : 
      28             : #endif

Generated by: LCOV version 1.14