rpcsx/rpcs3/Emu/RSX/Common/profiling_timer.hpp
kd-11 7b9fb7ad9c rsx: refactor rsx_utils a bit
- Move obviously standalone things to their own utility files
2021-09-28 17:43:15 +03:00

35 lines
491 B
C++

#pragma once
#include <util/types.hpp>
namespace rsx
{
struct profiling_timer
{
bool enabled = false;
steady_clock::time_point last;
profiling_timer() = default;
void start()
{
if (enabled) [[unlikely]]
{
last = steady_clock::now();
}
}
s64 duration()
{
if (!enabled) [[likely]]
{
return 0ll;
}
auto old = last;
last = steady_clock::now();
return std::chrono::duration_cast<std::chrono::microseconds>(last - old).count();
}
};
}