-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added: Timer class to time the computation of the approximation of co…
…untry borders
- Loading branch information
1 parent
f7b1d16
commit 92c6c17
Showing
4 changed files
with
90 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
|
||
#ifndef TIMER_H | ||
#define TIMER_H | ||
|
||
#include <chrono> | ||
#include <iostream> | ||
#include <string> | ||
|
||
|
||
class Timer | ||
{ | ||
public: | ||
Timer() | ||
{ | ||
reset(); | ||
} | ||
|
||
void reset() | ||
{ | ||
m_Start = std::chrono::high_resolution_clock::now(); | ||
} | ||
|
||
float elapsed() | ||
{ | ||
return std::chrono::duration_cast<std::chrono::nanoseconds>( | ||
std::chrono::high_resolution_clock::now() - m_Start).count() | ||
* 0.001f * 0.001f * 0.001f; | ||
} | ||
|
||
float elapsed_millis() | ||
{ | ||
return elapsed() * 1000.0f; | ||
} | ||
|
||
private: | ||
std::chrono::time_point<std::chrono::high_resolution_clock> m_Start; | ||
}; | ||
|
||
class ScopedTimer | ||
{ | ||
public: | ||
ScopedTimer(const std::string& name) | ||
: m_Name(name) {} | ||
~ScopedTimer() | ||
{ | ||
float time = m_Timer.elapsed_millis(); | ||
std::cout << "[TIMER] " << m_Name << " - " << time << "ms\n"; | ||
} | ||
private: | ||
std::string m_Name; | ||
Timer m_Timer; | ||
}; | ||
|
||
|
||
#endif |