mirror of
https://github.com/open-goal/jak-project
synced 2026-05-24 07:11:15 -04:00
Add a bunch of #ifdefs to keep things working as expected on linux
This commit is contained in:
@@ -71,8 +71,8 @@ void SystemThreadManager::join() {
|
||||
*/
|
||||
void* bootstrap_thread_func(void* x) {
|
||||
SystemThread* thd = (SystemThread*)x;
|
||||
SystemThreadInterface interfaces(thd);
|
||||
thd->function(interfaces);
|
||||
SystemThreadInterface interface(thd);
|
||||
thd->function(interface);
|
||||
printf("[SYSTEM] Thread %s is returning\n", thd->name.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
@@ -135,3 +135,36 @@ bool SystemThreadInterface::get_want_exit() const {
|
||||
void SystemThreadInterface::trigger_shutdown() {
|
||||
thread.manager->shutdown();
|
||||
}
|
||||
|
||||
// TODO-Windows
|
||||
#ifdef __linux__
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
/*!
|
||||
* Get thread performance statistics and report them.
|
||||
*/
|
||||
void SystemThreadInterface::report_perf_stats() {
|
||||
if (thread.stat_diff_timer.getMs() > 16.f) {
|
||||
thread.stat_diff_timer.start();
|
||||
|
||||
uint64_t current_ns = thread.stats_timer.getNs();
|
||||
rusage stats;
|
||||
getrusage(RUSAGE_THREAD, &stats);
|
||||
|
||||
uint64_t current_kernel = stats.ru_stime.tv_usec + (1000000 * stats.ru_stime.tv_sec);
|
||||
uint64_t current_user = stats.ru_utime.tv_usec + (1000000 * stats.ru_utime.tv_sec);
|
||||
|
||||
uint64_t ns_dt = current_ns - thread.last_collection_nanoseconds;
|
||||
uint64_t dt_kernel = current_kernel - thread.last_cpu_kernel;
|
||||
uint64_t dt_user = current_user - thread.last_cpu_user;
|
||||
|
||||
thread.cpu_kernel = dt_kernel * 1000. / (double)ns_dt;
|
||||
thread.cpu_user = dt_user * 1000. / (double)ns_dt;
|
||||
|
||||
thread.last_cpu_kernel = current_kernel;
|
||||
thread.last_cpu_user = current_user;
|
||||
thread.last_collection_nanoseconds = current_ns;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user