Intel® RealSense™ Cross Platform API
Intel Realsense Cross-platform API
Loading...
Searching...
No Matches
stopwatch.h
Go to the documentation of this file.
1// License: Apache 2.0. See LICENSE file in root directory.
2// Copyright(c) 2020 Intel Corporation. All Rights Reserved.
3
4#pragma once
5
6#include "common.h"
7
8namespace utilities
9{
10 namespace time
11 {
12 // Timer that counts forward in time (vs backwards in the 'timer' class)
13 // It supply a basic stopwatch API, reset, get elapsed time..
15 {
16 public:
17
19 {
20 _start = clock::now();
21 }
22
23 // Reset the stopwatch time
24 void reset(clock::time_point start_time = clock::now()) const
25 {
26 _start = start_time;
27 }
28
29 // Get elapsed in milliseconds since timer creation
30 double get_elapsed_ms() const
31 {
32 return std::chrono::duration_cast<std::chrono::duration<double, std::milli>>(get_elapsed()).count();
33 }
34
35 // Get elapsed since timer creation
36 clock::duration get_elapsed() const
37 {
38 return clock::now() - _start;
39 }
40
41 // Get stopwatch start time
42 clock::time_point get_start() const
43 {
44 return _start;
45 }
46
47 protected:
48 mutable clock::time_point _start;
49 };
50 }
51}
Definition: stopwatch.h:15
clock::duration get_elapsed() const
Definition: stopwatch.h:36
clock::time_point get_start() const
Definition: stopwatch.h:42
void reset(clock::time_point start_time=clock::now()) const
Definition: stopwatch.h:24
stopwatch()
Definition: stopwatch.h:18
double get_elapsed_ms() const
Definition: stopwatch.h:30
clock::time_point _start
Definition: stopwatch.h:48
Definition: stabilized-value.h:12