diff --git a/rpcs3/Emu/Cell/lv2/lv2.cpp b/rpcs3/Emu/Cell/lv2/lv2.cpp index 698fd3fc07..1d1a9978e0 100644 --- a/rpcs3/Emu/Cell/lv2/lv2.cpp +++ b/rpcs3/Emu/Cell/lv2/lv2.cpp @@ -1093,21 +1093,23 @@ class ppu_syscall_usage { // Internal buffer std::string m_stats; + u64 m_old_stat[1024]{}; public: // Public info collection buffers atomic_t stat[1024]{}; - void print_stats() noexcept + void print_stats(bool force_print) noexcept { std::multimap> usage; for (u32 i = 0; i < 1024; i++) { - if (u64 v = stat[i]) + if (u64 v = stat[i]; m_old_stat[i] != v || (force_print && v)) { - // Only add syscalls with non-zero usage counter + // Only add syscalls with non-zero usage counter and only if caught new calls since last print usage.emplace(v, i); + m_old_stat[i] = v; } } @@ -1118,27 +1120,36 @@ public: fmt::append(m_stats, u8"\n\t⁂ %s [%u]", ppu_get_syscall_name(pair.second), pair.first); } - ppu_log.notice("PPU Syscall Usage Stats: %s", m_stats); + if (!m_stats.empty()) + { + ppu_log.notice("PPU Syscall Usage Stats: %s", m_stats); + } } void operator()() { - while (thread_ctrl::state() != thread_state::aborting) + bool was_paused = false; + + for (u32 i = 1; thread_ctrl::state() != thread_state::aborting; i++) { - thread_ctrl::wait_for(10000'000); + thread_ctrl::wait_for(1'000'000); - if (Emu.IsPaused()) + const bool is_paused = Emu.IsPaused(); + + // Force-print all if paused + const bool force_print = is_paused && !was_paused; + + if (force_print || i % 10 == 0) { - continue; + was_paused = is_paused; + print_stats(force_print); } - - print_stats(); } } ~ppu_syscall_usage() { - print_stats(); + print_stats(true); } static constexpr auto thread_name = "PPU Syscall Usage Thread"sv;