System: Add GetProcessUptime()

This commit is contained in:
Stenzek
2026-01-12 17:27:48 +10:00
parent a83ccdcd0e
commit 8f94a56ab2
2 changed files with 13 additions and 1 deletions

View File

@@ -330,11 +330,14 @@ struct ALIGN_TO_CACHE_LINE StateVars
std::optional<UndoSaveStateBuffer> undo_load_state;
// Used to track play time. We use a monotonic timer here, in case of clock changes.
u64 session_start_time = 0;
Timer::Value session_start_time = 0;
// internal async task counters
std::atomic_uint32_t outstanding_save_state_tasks{0};
// process start time
Timer::Value process_start_time = 0;
#ifdef ENABLE_SOCKET_MULTIPLEXER
std::unique_ptr<SocketMultiplexer> socket_multiplexer;
#endif
@@ -507,6 +510,7 @@ bool System::ProcessStartup(Error* error)
return false;
#endif
s_state.process_start_time = Timer::GetCurrentValue();
return true;
}
@@ -516,6 +520,11 @@ void System::ProcessShutdown()
CPU::CodeCache::ProcessShutdown();
}
float System::GetProcessUptime()
{
return static_cast<float>(Timer::ConvertValueToSeconds(Timer::GetCurrentValue() - s_state.process_start_time));
}
bool System::CoreThreadInitialize(Error* error)
{
#ifdef _WIN32

View File

@@ -68,6 +68,9 @@ bool ProcessStartup(Error* error);
/// Called on process shutdown.
void ProcessShutdown();
/// Returns the number of seconds since the process started.
float GetProcessUptime();
/// Called on CPU thread initialization.
bool CoreThreadInitialize(Error* error);