mirror of
https://github.com/RPCSX/rpcsx.git
synced 2025-12-31 13:50:46 +01:00
35 lines
491 B
C++
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();
|
|
}
|
|
};
|
|
}
|