mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-03 21:41:26 +12:00
Add more thread information (context switch, page faults).
Only implemented on Linux, possibly works on some BSD.
This commit is contained in:
parent
8b4b859091
commit
e772dde3cc
1 changed files with 15 additions and 2 deletions
|
@ -1816,14 +1816,26 @@ bool thread_base::finalize(int) noexcept
|
||||||
FILETIME ctime, etime, ktime, utime;
|
FILETIME ctime, etime, ktime, utime;
|
||||||
GetThreadTimes(GetCurrentThread(), &ctime, &etime, &ktime, &utime);
|
GetThreadTimes(GetCurrentThread(), &ctime, &etime, &ktime, &utime);
|
||||||
const u64 time = ((ktime.dwLowDateTime | (u64)ktime.dwHighDateTime << 32) + (utime.dwLowDateTime | (u64)utime.dwHighDateTime << 32)) * 100ull;
|
const u64 time = ((ktime.dwLowDateTime | (u64)ktime.dwHighDateTime << 32) + (utime.dwLowDateTime | (u64)utime.dwHighDateTime << 32)) * 100ull;
|
||||||
|
const u64 fsoft = 0;
|
||||||
|
const u64 fhard = 0;
|
||||||
|
const u64 ctxvol = 0;
|
||||||
|
const u64 ctxinv = 0;
|
||||||
#elif defined(RUSAGE_THREAD)
|
#elif defined(RUSAGE_THREAD)
|
||||||
const u64 cycles = 0; // Not supported
|
const u64 cycles = 0; // Not supported
|
||||||
struct ::rusage stats{};
|
struct ::rusage stats{};
|
||||||
::getrusage(RUSAGE_THREAD, &stats);
|
::getrusage(RUSAGE_THREAD, &stats);
|
||||||
const u64 time = (stats.ru_utime.tv_sec + stats.ru_stime.tv_sec) * 1000000000ull + (stats.ru_utime.tv_usec + stats.ru_stime.tv_usec) * 1000ull;
|
const u64 time = (stats.ru_utime.tv_sec + stats.ru_stime.tv_sec) * 1000000000ull + (stats.ru_utime.tv_usec + stats.ru_stime.tv_usec) * 1000ull;
|
||||||
|
const u64 fsoft = stats.ru_minflt;
|
||||||
|
const u64 fhard = stats.ru_majflt;
|
||||||
|
const u64 ctxvol = stats.ru_nvcsw;
|
||||||
|
const u64 ctxinv = stats.ru_nivcsw;
|
||||||
#else
|
#else
|
||||||
const u64 cycles = 0;
|
const u64 cycles = 0;
|
||||||
const u64 time = 0;
|
const u64 time = 0;
|
||||||
|
const u64 fsoft = 0;
|
||||||
|
const u64 fhard = 0;
|
||||||
|
const u64 ctxvol = 0;
|
||||||
|
const u64 ctxinv = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
g_tls_log_prefix = []
|
g_tls_log_prefix = []
|
||||||
|
@ -1831,12 +1843,13 @@ bool thread_base::finalize(int) noexcept
|
||||||
return thread_ctrl::g_tls_this_thread->m_name.get();
|
return thread_ctrl::g_tls_this_thread->m_name.get();
|
||||||
};
|
};
|
||||||
|
|
||||||
sig_log.notice("Thread time: %fs (%fGc); Faults: %u [rsx:%u, spu:%u];",
|
sig_log.notice("Thread time: %fs (%fGc); Faults: %u [rsx:%u, spu:%u]; [soft:%u hard:%u]; Switches:[vol:%u unvol:%u]",
|
||||||
time / 1000000000.,
|
time / 1000000000.,
|
||||||
cycles / 1000000000.,
|
cycles / 1000000000.,
|
||||||
g_tls_fault_all,
|
g_tls_fault_all,
|
||||||
g_tls_fault_rsx,
|
g_tls_fault_rsx,
|
||||||
g_tls_fault_spu);
|
g_tls_fault_spu,
|
||||||
|
fsoft, fhard, ctxvol, ctxinv);
|
||||||
|
|
||||||
// Return true if need to delete thread object
|
// Return true if need to delete thread object
|
||||||
const bool result = m_state.exchange(thread_state::finished) == thread_state::detached;
|
const bool result = m_state.exchange(thread_state::finished) == thread_state::detached;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue