getUserTime reports the current amount of user cpu time accumulated by this StopWatch. If the stop_watch is currently off, this is just the accumulated time. If the StopWatch is running, this is the accumulated time plus the time since the stop_watch was last started.
| 157 | //this is just the accumulated time. If the StopWatch is running, this |
| 158 | //is the accumulated time plus the time since the stop_watch was last started. |
| 159 | double StopWatch::getUserTime() const |
| 160 | { |
| 161 | if (is_running_ == false) |
| 162 | { |
| 163 | /* stop_watch is currently off, so just return accumulated time */ |
| 164 | return accumulated_times_.userTime(); |
| 165 | } |
| 166 | |
| 167 | /* stop_watch is currently running, so add the elapsed time since */ |
| 168 | /* the stop_watch was last started to the accumulated time */ |
| 169 | auto now = snapShot_(); |
| 170 | auto diff = now - last_start_; |
| 171 | |
| 172 | /* convert into floating point number of seconds */ |
| 173 | return accumulated_times_.userTime() + diff.userTime(); |
| 174 | } |
| 175 | |
| 176 | // system_time reports the current amount of system cpu time |
| 177 | // accumulated by this StopWatch. If the stop_watch is currently off, |
no test coverage detected