LCOV - code coverage report
Current view: top level - src/rdl/rdl_benchmark/include/rdl_benchmark - Timer.hpp (source / functions) Hit Total Coverage
Test: projectcoverage.info Lines: 0 9 0.0 %
Date: 2024-12-13 18:04:46 Functions: 0 2 0.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : // Copyright (c) 2017 Jordan Lack <jlack1987@gmail.com>
       2                 :            : // Copyright (c) 2011-2016 Martin Felis <martin.felis@iwr.uni-heidelberg.de>
       3                 :            : // RDL - Robot Dynamics Library
       4                 :            : // Licensed under the zlib license. See LICENSE for more details.
       5                 :            : 
       6                 :            : #ifndef _TIMER_H
       7                 :            : #define _TIMER_H
       8                 :            : 
       9                 :            : #include <ctime>
      10                 :            : 
      11                 :            : struct TimerInfo
      12                 :            : {
      13                 :            :     /// time stamp when timer_start() gets called
      14                 :            :     double clock_start_value;
      15                 :            : 
      16                 :            :     /// time stamp when the timer was stopped
      17                 :            :     double clock_end_value;
      18                 :            : 
      19                 :            :     /// duration between clock_start_value and clock_end_value in seconds
      20                 :            :     double duration_sec;
      21                 :            : };
      22                 :            : 
      23                 :          0 : inline void timer_start(TimerInfo* timer)
      24                 :            : {
      25                 :            :     struct timespec system_time_; /**< time struct */
      26                 :          0 :     clock_gettime(CLOCK_REALTIME, &system_time_);
      27                 :            : 
      28                 :          0 :     timer->clock_start_value = static_cast<double>(system_time_.tv_sec) + static_cast<double>(system_time_.tv_nsec) * 1.e-9;
      29                 :          0 : }
      30                 :            : 
      31                 :          0 : inline double timer_stop(TimerInfo* timer)
      32                 :            : {
      33                 :            :     struct timespec system_time_; /**< time struct */
      34                 :          0 :     clock_gettime(CLOCK_REALTIME, &system_time_);
      35                 :            : 
      36                 :          0 :     timer->clock_end_value = static_cast<double>(system_time_.tv_sec) + static_cast<double>(system_time_.tv_nsec) * 1.e-9;
      37                 :            : 
      38                 :          0 :     timer->duration_sec = timer->clock_end_value - timer->clock_start_value;
      39                 :            : 
      40                 :          0 :     return timer->duration_sec;
      41                 :            : }
      42                 :            : 
      43                 :            : #endif

Generated by: LCOV version 1.14