Bubba-3D  0.9.0
Awesome game engine!
timer.h
1 /*
2  * This file is part of Bubba-3D.
3  *
4  * Bubba-3D is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * Bubba-3D is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with Bubba-3D. If not, see http://www.gnu.org/licenses/.
16  */
17 #pragma once
18 
19 #ifdef _WIN32
20 #include <chrono>
21 
22 using namespace std::chrono;
23 #endif
24 
25 #ifdef __linux__
26 #include <sys/time.h>
27 #endif
28 
29 namespace utils {
30 class Timer {
31 public:
32  void start();
33  void stop();
34  double getElapsedTime();
35 
36 private:
37 
38 #ifdef __linux__
39  struct timeval tStart;
40  struct timeval tEnd;
41 #endif
42 
43 #ifdef _WIN32
44  high_resolution_clock::time_point tEnd;
45  high_resolution_clock::time_point tStart;
46 #endif
47 };
48 
49 }
Definition: timer.h:29