2023-07-10 15:29:38 +00:00
|
|
|
/***
|
|
|
|
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"
|
2023-07-10 20:37:28 +00:00
|
|
|
#include <Time/Time.hpp>
|
2023-07-10 15:29:38 +00:00
|
|
|
|
|
|
|
namespace Aurora::Process
|
|
|
|
{
|
|
|
|
AUKN_SYM AuUInt64 GetProcessStartupTimeNS()
|
|
|
|
{
|
|
|
|
static AuOptional<AuUInt64> optKnownWallTime;
|
|
|
|
|
|
|
|
if (optKnownWallTime.has_value())
|
|
|
|
{
|
|
|
|
return optKnownWallTime.value();
|
|
|
|
}
|
|
|
|
|
2023-07-10 20:37:28 +00:00
|
|
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
|
|
|
FILETIME creation, exit, kernel, user;
|
|
|
|
if (::GetProcessTimes(GetCurrentProcess(), &creation, &exit, &kernel, &user))
|
2023-07-10 15:29:38 +00:00
|
|
|
{
|
2023-07-10 20:37:28 +00:00
|
|
|
optKnownWallTime = AuTime::ConvertTimestampNs(creation);
|
2023-07-10 15:29:38 +00:00
|
|
|
}
|
2023-07-10 20:37:28 +00:00
|
|
|
#else
|
|
|
|
optKnownWallTime = AuTime::CurrentClockNS() - AuTime::ThreadClockNS();
|
|
|
|
#endif
|
2023-07-10 15:29:38 +00:00
|
|
|
|
|
|
|
return optKnownWallTime.value();
|
|
|
|
}
|
|
|
|
|
|
|
|
AUKN_SYM AuUInt64 GetProcessStartupTimeMS()
|
|
|
|
{
|
|
|
|
return AuNSToMS<AuUInt64>(GetProcessStartupTimeNS());
|
|
|
|
}
|
|
|
|
}
|