mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-05 06:26:49 +00:00
Fix perf_meter<> after adding thread pool.
Print and reset sorted information after emulation stop/pause. Print useless average value.
This commit is contained in:
parent
3e1344e4e4
commit
d4d5dc99f3
3 changed files with 85 additions and 17 deletions
|
|
@ -1,11 +1,19 @@
|
|||
#include "stdafx.h"
|
||||
#include "perf_meter.hpp"
|
||||
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
|
||||
void perf_stat_base::push(u64 ns[66]) noexcept
|
||||
{
|
||||
if (!ns[0])
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (u32 i = 0; i < 66; i++)
|
||||
{
|
||||
m_log[i] += ns[i];
|
||||
m_log[i] += atomic_storage<u64>::exchange(ns[i], 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -13,7 +21,7 @@ void perf_stat_base::print(const char* name) noexcept
|
|||
{
|
||||
if (u64 num_total = m_log[0].load())
|
||||
{
|
||||
perf_log.notice("Perf stats for %s: total events: %u (total time %.4fs)", name, num_total, m_log[65].load() / 1000'000'000.);
|
||||
perf_log.notice(u8"Perf stats for %s: total events: %u (total time %.4fs, avg %.4fµs)", name, num_total, m_log[65].load() / 1000'000'000., m_log[65].load() / 1000. / num_total);
|
||||
|
||||
for (u32 i = 0; i < 13; i++)
|
||||
{
|
||||
|
|
@ -56,3 +64,55 @@ void perf_stat_base::print(const char* name) noexcept
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
static shared_mutex s_perf_mutex;
|
||||
|
||||
static std::map<std::string, perf_stat_base> s_perf_acc;
|
||||
|
||||
static std::multimap<std::string, u64*> s_perf_sources;
|
||||
|
||||
void perf_stat_base::add(u64 ns[66], const char* name) noexcept
|
||||
{
|
||||
std::lock_guard lock(s_perf_mutex);
|
||||
|
||||
s_perf_sources.emplace(name, ns);
|
||||
s_perf_acc[name];
|
||||
}
|
||||
|
||||
void perf_stat_base::remove(u64 ns[66], const char* name) noexcept
|
||||
{
|
||||
std::lock_guard lock(s_perf_mutex);
|
||||
|
||||
const auto found = s_perf_sources.equal_range(name);
|
||||
|
||||
for (auto it = found.first; it != found.second; it++)
|
||||
{
|
||||
if (it->second == ns)
|
||||
{
|
||||
s_perf_acc[name].push(ns);
|
||||
s_perf_sources.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void perf_stat_base::report() noexcept
|
||||
{
|
||||
std::lock_guard lock(s_perf_mutex);
|
||||
|
||||
perf_log.notice("Performance report begin (%u src, %u acc):", s_perf_sources.size(), s_perf_acc.size());
|
||||
|
||||
for (auto& [name, ns] : s_perf_sources)
|
||||
{
|
||||
s_perf_acc[name].push(ns);
|
||||
}
|
||||
|
||||
for (auto& [name, data] : s_perf_acc)
|
||||
{
|
||||
data.print(name.c_str());
|
||||
}
|
||||
|
||||
s_perf_acc.clear();
|
||||
|
||||
perf_log.notice("Performance report end.");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue