imate
C++/CUDA Reference
timer.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright 2021, Siavash Ameli <sameli@berkeley.edu>
3  * SPDX-License-Identifier: BSD-3-Clause
4  * SPDX-FileType: SOURCE
5  *
6  * This program is free software: you can redistribute it and/or modify it
7  * under the terms of the license found in the LICENSE.txt file in the root
8  * directory of this source tree.
9  */
10 
11 
12 #ifndef _UTILITIES_TIMER_H_
13 #define _UTILITIES_TIMER_H_
14 
15 
16 // =====
17 // Timer
18 // =====
19 
48 
49 class Timer
50 {
51  public:
52 
53  Timer();
54  ~Timer();
55  void start();
56  void stop();
57  double elapsed() const;
58 
59  protected:
60 
61  static double get_wall_time();
62 
63  // Data
64  double start_time;
65  double stop_time;
66 };
67 
68 #endif // _UTILITIES_TIMER_H_
Records elasped wall time between two events.
Definition: timer.h:50
~Timer()
Destructor for Timer.
Definition: timer.cpp:54
void start()
Starts the timer.
Definition: timer.cpp:66
static double get_wall_time()
Returns the wall time since the epoch.
Definition: timer.cpp:105
Timer()
constructor for Timer
Definition: timer.cpp:40
void stop()
Stops the timer.
Definition: timer.cpp:79
double start_time
Definition: timer.h:64
double elapsed() const
Returns the elapsed time in seconds.
Definition: timer.cpp:92
double stop_time
Definition: timer.h:65