mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-10 17:01:24 +12:00
perf_meter.hpp: fix double rdtsc bug, add restart() method
This commit is contained in:
parent
006c783aba
commit
e794109a67
2 changed files with 13 additions and 9 deletions
|
@ -2750,9 +2750,7 @@ bool spu_thread::process_mfc_cmd()
|
||||||
std::this_thread::yield();
|
std::this_thread::yield();
|
||||||
|
|
||||||
// Reset perf
|
// Reset perf
|
||||||
perf_meter<'x'> dummy;
|
perf0.restart();
|
||||||
perf0 = dummy;
|
|
||||||
dummy.reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
alignas(64) spu_rdata_t temp;
|
alignas(64) spu_rdata_t temp;
|
||||||
|
|
|
@ -83,18 +83,17 @@ template <auto ShortName, auto... SubEvents>
|
||||||
class perf_meter
|
class perf_meter
|
||||||
{
|
{
|
||||||
// Initialize array (possibly only 1 element) with timestamp
|
// Initialize array (possibly only 1 element) with timestamp
|
||||||
u64 m_timestamps[1 + sizeof...(SubEvents)] = {__rdtsc()};
|
u64 m_timestamps[1 + sizeof...(SubEvents)];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SAFE_BUFFERS perf_meter() noexcept
|
SAFE_BUFFERS FORCE_INLINE perf_meter() noexcept
|
||||||
{
|
{
|
||||||
m_timestamps[0] = __rdtsc();
|
restart();
|
||||||
std::memset(m_timestamps + 1, 0, sizeof(m_timestamps) - sizeof(u64));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy first timestamp
|
// Copy first timestamp
|
||||||
template <auto SN, auto... S>
|
template <auto SN, auto... S>
|
||||||
SAFE_BUFFERS perf_meter(const perf_meter<SN, S...>& r) noexcept
|
SAFE_BUFFERS FORCE_INLINE perf_meter(const perf_meter<SN, S...>& r) noexcept
|
||||||
{
|
{
|
||||||
m_timestamps[0] = r.get();
|
m_timestamps[0] = r.get();
|
||||||
std::memset(m_timestamps + 1, 0, sizeof(m_timestamps) - sizeof(u64));
|
std::memset(m_timestamps + 1, 0, sizeof(m_timestamps) - sizeof(u64));
|
||||||
|
@ -147,11 +146,18 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable this counter
|
// Disable this counter
|
||||||
SAFE_BUFFERS void reset() noexcept
|
SAFE_BUFFERS FORCE_INLINE void reset() noexcept
|
||||||
{
|
{
|
||||||
m_timestamps[0] = 0;
|
m_timestamps[0] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Re-initialize first timestamp
|
||||||
|
SAFE_BUFFERS FORCE_INLINE void restart() noexcept
|
||||||
|
{
|
||||||
|
m_timestamps[0] = __rdtsc();
|
||||||
|
std::memset(m_timestamps + 1, 0, sizeof(m_timestamps) - sizeof(u64));
|
||||||
|
}
|
||||||
|
|
||||||
SAFE_BUFFERS ~perf_meter()
|
SAFE_BUFFERS ~perf_meter()
|
||||||
{
|
{
|
||||||
// Disabled counter
|
// Disabled counter
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue