[+] AuProcess::GetProcessStartupSteadyTimeNS()

This commit is contained in:
Reece Wilson 2023-12-13 22:13:28 +00:00
parent 1652231fd4
commit a5f4d959be
3 changed files with 32 additions and 2 deletions

View File

@ -11,11 +11,16 @@ namespace Aurora::Process
{
/**
* @brief Defer to the AuTime namespace to convert the return unsigned integer to something useful
*/
*/
AUKN_SYM AuUInt64 GetProcessStartupTimeNS();
/**
* @brief Defer to the AuTime namespace to convert the return unsigned integer to something useful
*/
*/
AUKN_SYM AuUInt64 GetProcessStartupTimeMS();
/**
* @brief Defer to AuTime::SteadyClockNS()
*/
AUKN_SYM AuUInt64 GetProcessStartupSteadyTimeNS();
}

View File

@ -73,6 +73,7 @@ static void Init()
Aurora::IO::TLS::TLSInit();
(void)AuProcess::GetProcessStartupTimeMS();
(void)AuProcess::GetProcessStartupSteadyTimeNS();
Aurora::Threading::InitSleep();
Aurora::Process::InitProcess();

View File

@ -37,4 +37,28 @@ namespace Aurora::Process
{
return AuNSToMS<AuUInt64>(GetProcessStartupTimeNS());
}
AUKN_SYM AuUInt64 GetProcessStartupSteadyTimeNS()
{
static AuOptional<AuUInt64> optKnownTime;
if (optKnownTime.has_value())
{
return optKnownTime.value();
}
#if defined(AURORA_IS_MODERNNT_DERIVED)
FILETIME creation, exit, kernel, user;
if (::GetProcessTimes(GetCurrentProcess(), &creation, &exit, &kernel, &user))
{
auto u64 = AuTime::ConvertTimestampNs(creation);
u64 += AuTime::SteadyClockNS() - AuTime::CurrentClockNS();
optKnownTime = u64;
}
#else
optKnownTime = AuTime::SteadyClockNS() - AuTime::ThreadClockNS();
#endif
return optKnownTime.value();
}
}