LCOV - code coverage report
Current view: top level - buildbot/coverage/build/src/util - statistics_stats.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 45 45 100.0 %
Date: 2026-01-20 13:04:20 Functions: 12 12 100.0 %
Branches: 16 24 66.7 %

           Branch data     Line data    Source code
       1                 :            : /******************************************************************************
       2                 :            :  * Top contributors (to current version):
       3                 :            :  *   Gereon Kremer, Matthew Sotoudeh
       4                 :            :  *
       5                 :            :  * This file is part of the cvc5 project.
       6                 :            :  *
       7                 :            :  * Copyright (c) 2009-2025 by the authors listed in the file AUTHORS
       8                 :            :  * in the top-level source directory and their institutional affiliations.
       9                 :            :  * All rights reserved.  See the file COPYING in the top-level source
      10                 :            :  * directory for licensing information.
      11                 :            :  * ****************************************************************************
      12                 :            :  *
      13                 :            :  * Basic statistics representation.
      14                 :            :  */
      15                 :            : 
      16                 :            : #include "util/statistics_stats.h"
      17                 :            : 
      18                 :            : #include "base/check.h"
      19                 :            : #include "util/statistics_value.h"
      20                 :            : 
      21                 :            : namespace cvc5::internal {
      22                 :            : 
      23                 :    3404520 : AverageStat& AverageStat::operator<<(double v)
      24                 :            : {
      25                 :            :   if constexpr (configuration::isStatisticsBuild())
      26                 :            :   {
      27                 :    3404520 :     d_data->d_sum += v;
      28                 :    3404520 :     d_data->d_count++;
      29                 :            :   }
      30                 :    3404520 :   return *this;
      31                 :            : }
      32                 :            : 
      33                 :      49646 : IntStat& IntStat::operator=(int64_t val)
      34                 :            : {
      35                 :            :   if constexpr (configuration::isStatisticsBuild())
      36                 :            :   {
      37                 :      49646 :     d_data->d_value = val;
      38                 :            :   }
      39                 :      49646 :   return *this;
      40                 :            : }
      41                 :            : 
      42                 :  330237000 : IntStat& IntStat::operator++()
      43                 :            : {
      44                 :            :   if constexpr (configuration::isStatisticsBuild())
      45                 :            :   {
      46                 :  330237000 :     d_data->d_value++;
      47                 :            :   }
      48                 :  330237000 :   return *this;
      49                 :            : }
      50                 :            : 
      51                 :   12086400 : IntStat& IntStat::operator++(int)
      52                 :            : {
      53                 :            :   if constexpr (configuration::isStatisticsBuild())
      54                 :            :   {
      55                 :   12086400 :     d_data->d_value++;
      56                 :            :   }
      57                 :   12086400 :   return *this;
      58                 :            : }
      59                 :            : 
      60                 :      90029 : IntStat& IntStat::operator+=(int64_t val)
      61                 :            : {
      62                 :            :   if constexpr (configuration::isStatisticsBuild())
      63                 :            :   {
      64                 :      90029 :     d_data->d_value += val;
      65                 :            :   }
      66                 :      90029 :   return *this;
      67                 :            : }
      68                 :            : 
      69                 :    5268010 : void IntStat::maxAssign(int64_t val)
      70                 :            : {
      71                 :            :   if constexpr (configuration::isStatisticsBuild())
      72                 :            :   {
      73         [ +  + ]:    5268010 :     if (d_data->d_value < val)
      74                 :            :     {
      75                 :     612113 :       d_data->d_value = val;
      76                 :            :     }
      77                 :            :   }
      78                 :    5268010 : }
      79                 :            : 
      80                 :       1867 : void IntStat::minAssign(int64_t val)
      81                 :            : {
      82                 :            :   if constexpr (configuration::isStatisticsBuild())
      83                 :            :   {
      84         [ +  + ]:       1867 :     if (d_data->d_value > val)
      85                 :            :     {
      86                 :        433 :       d_data->d_value = val;
      87                 :            :     }
      88                 :            :   }
      89                 :       1867 : }
      90                 :            : 
      91                 :   37609700 : void TimerStat::start()
      92                 :            : {
      93                 :            :   if constexpr (configuration::isStatisticsBuild())
      94                 :            :   {
      95 [ -  + ][ -  + ]:   37609700 :     Assert(!d_data->d_running) << "timer is already running";
                 [ -  - ]
      96                 :   37609700 :     d_data->d_start = StatisticTimerValue::clock::now();
      97                 :   37609700 :     d_data->d_running = true;
      98                 :            :   }
      99                 :   37609700 : }
     100                 :   37535000 : void TimerStat::stop()
     101                 :            : {
     102                 :            :   if constexpr (configuration::isStatisticsBuild())
     103                 :            :   {
     104 [ -  + ][ -  + ]:   37535000 :     Assert(d_data->d_running) << "timer is not running";
                 [ -  - ]
     105                 :   37535000 :     d_data->d_duration += StatisticTimerValue::clock::now() - d_data->d_start;
     106                 :   37535000 :     d_data->d_running = false;
     107                 :            :   }
     108                 :   37535000 : }
     109                 :    9043480 : bool TimerStat::running() const
     110                 :            : {
     111                 :            :   if constexpr (configuration::isStatisticsBuild())
     112                 :            :   {
     113                 :    9043480 :     return d_data->d_running;
     114                 :            :   }
     115                 :            :   return false;
     116                 :            : }
     117                 :            : 
     118                 :   37593600 : CodeTimer::CodeTimer(TimerStat& timer, bool allow_reentrant)
     119                 :   37593600 :     : d_timer(timer), d_reentrant(false)
     120                 :            : {
     121                 :            :   if constexpr (configuration::isStatisticsBuild())
     122                 :            :   {
     123 [ +  + ][ +  + ]:   37593600 :     if (!allow_reentrant || !(d_reentrant = d_timer.running()))
                 [ +  + ]
     124                 :            :     {
     125                 :   37535000 :       d_timer.start();
     126                 :            :     }
     127                 :            :   }
     128                 :   37593600 : }
     129                 :   75187300 : CodeTimer::~CodeTimer()
     130                 :            : {
     131                 :            :   if constexpr (configuration::isStatisticsBuild())
     132                 :            :   {
     133         [ +  + ]:   37593600 :     if (!d_reentrant)
     134                 :            :     {
     135                 :   37535000 :       d_timer.stop();
     136                 :            :     }
     137                 :            :   }
     138                 :   37593600 : }
     139                 :            : 
     140                 :            : }  // namespace cvc5::internal

Generated by: LCOV version 1.14