AuroraRuntime/Source/Process/AuProcessStartTime.cpp

40 lines
1.0 KiB
C++
Raw Normal View History

/***
Copyright (C) 2023 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: AuProcessStartTime.cpp
Date: 2023-7-10
Author: Reece
***/
#include <Source/RuntimeInternal.hpp>
#include "AuProcessStartTime.hpp"
#include <Time/Time.hpp>
namespace Aurora::Process
{
AUKN_SYM AuUInt64 GetProcessStartupTimeNS()
{
static AuOptional<AuUInt64> optKnownWallTime;
if (optKnownWallTime.has_value())
{
return optKnownWallTime.value();
}
#if defined(AURORA_IS_MODERNNT_DERIVED)
FILETIME creation, exit, kernel, user;
if (::GetProcessTimes(GetCurrentProcess(), &creation, &exit, &kernel, &user))
{
optKnownWallTime = AuTime::ConvertTimestampNs(creation);
}
#else
optKnownWallTime = AuTime::CurrentClockNS() - AuTime::ThreadClockNS();
#endif
return optKnownWallTime.value();
}
AUKN_SYM AuUInt64 GetProcessStartupTimeMS()
{
return AuNSToMS<AuUInt64>(GetProcessStartupTimeNS());
}
}