Initial setup for CLion
This commit is contained in:
20
engines/TensorRTAPI/include/util/Stopwatch.h
Normal file
20
engines/TensorRTAPI/include/util/Stopwatch.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
#include <chrono>
|
||||
|
||||
// Utility Timer
|
||||
template <typename Clock = std::chrono::high_resolution_clock> class Stopwatch {
|
||||
typename Clock::time_point start_point;
|
||||
|
||||
public:
|
||||
Stopwatch() : start_point(Clock::now()) {}
|
||||
|
||||
// Returns elapsed time
|
||||
template <typename Rep = typename Clock::duration::rep, typename Units = typename Clock::duration> Rep elapsedTime() const {
|
||||
std::atomic_thread_fence(std::memory_order_relaxed);
|
||||
auto counted_time = std::chrono::duration_cast<Units>(Clock::now() - start_point).count();
|
||||
std::atomic_thread_fence(std::memory_order_relaxed);
|
||||
return static_cast<Rep>(counted_time);
|
||||
}
|
||||
};
|
||||
|
||||
using preciseStopwatch = Stopwatch<>;
|
||||
Reference in New Issue
Block a user