mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-06 06:51:26 +12:00
perf_meter.hpp: move logic to noinline function
May improve performance if perf meter is disabled.
This commit is contained in:
parent
2b674d4d8c
commit
95b8467a76
1 changed files with 17 additions and 14 deletions
|
@ -72,8 +72,23 @@ class perf_stat final : public perf_stat_base
|
||||||
} g_tls_perf_stat;
|
} g_tls_perf_stat;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void push(u64 ns) noexcept
|
static NEVER_INLINE void push(u64 start_time) noexcept
|
||||||
{
|
{
|
||||||
|
// Event end
|
||||||
|
const u64 end_time = (_mm_lfence(), __rdtsc());
|
||||||
|
|
||||||
|
// Compute difference in seconds
|
||||||
|
const f64 diff = (end_time - start_time) * 1. / utils::get_tsc_freq();
|
||||||
|
|
||||||
|
// Register perf stat in nanoseconds
|
||||||
|
const u64 ns = static_cast<u64>(diff * 1000'000'000.);
|
||||||
|
|
||||||
|
// Print in microseconds
|
||||||
|
if (static_cast<u64>(diff * 1000'000.) >= g_cfg.core.perf_report_threshold)
|
||||||
|
{
|
||||||
|
perf_log.notice(u8"%s: %.3fµs", perf_name<ShortName>.data(), diff * 1000'000.);
|
||||||
|
}
|
||||||
|
|
||||||
auto& data = g_tls_perf_stat.m_log;
|
auto& data = g_tls_perf_stat.m_log;
|
||||||
data[0] += ns != 0;
|
data[0] += ns != 0;
|
||||||
data[64 - std::countl_zero(ns)]++;
|
data[64 - std::countl_zero(ns)]++;
|
||||||
|
@ -174,20 +189,8 @@ public:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Event end
|
|
||||||
const u64 end_time = __rdtsc();
|
|
||||||
|
|
||||||
// Compute difference in seconds
|
|
||||||
const f64 diff = (end_time - m_timestamps[0]) * 1. / utils::get_tsc_freq();
|
|
||||||
|
|
||||||
// Register perf stat in nanoseconds
|
// Register perf stat in nanoseconds
|
||||||
perf_stat<ShortName>::push(static_cast<u64>(diff * 1000'000'000.));
|
perf_stat<ShortName>::push(m_timestamps[0]);
|
||||||
|
|
||||||
// Print in microseconds
|
|
||||||
if (static_cast<u64>(diff * 1000'000.) >= g_cfg.core.perf_report_threshold)
|
|
||||||
{
|
|
||||||
perf_log.notice(u8"%s: %.3fµs", perf_name<ShortName>.data(), diff * 1000'000.);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: handle push(), currently ignored
|
// TODO: handle push(), currently ignored
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue