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 
8 namespace 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..
14  class stopwatch
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 }
clock::time_point _start
Definition: stopwatch.h:48
clock::time_point get_start() const
Definition: stopwatch.h:42
void reset(clock::time_point start_time=clock::now()) const
Definition: stopwatch.h:24
double get_elapsed_ms() const
Definition: stopwatch.h:30
GLint GLsizei count
clock::duration get_elapsed() const
Definition: stopwatch.h:36


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:50:11