[*] UNIX benchmarks: follow CLOCK_PROCESS_CPUTIME_ID time

This commit is contained in:
Reece Wilson 2022-12-27 19:41:52 +00:00
parent 0be7c13e1b
commit 6e78ce5e07

View File

@ -211,16 +211,26 @@ namespace Aurora::Time
AUKN_SYM AuUInt64 HighResClockMS()
{
#if defined(AURORA_IS_POSIX_DERIVED)
return SteadyClockMS();
::timespec spec {};
if (::clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &spec) == 0)
{
return AuSToMS<AuUInt64>(spec.tv_sec) + AuNSToMS<AuUInt64>(spec.tv_nsec);
}
#endif
return std::chrono::duration_cast<std::chrono::milliseconds>(high_res_clock::now().time_since_epoch()).count();
}
AUKN_SYM AuUInt64 HighResClockNS()
{
#if defined(AURORA_IS_POSIX_DERIVED)
return SteadyClockNS();
::timespec spec {};
if (::clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &spec) == 0)
{
return AuMSToNS<AuUInt64>(AuSToMS<AuUInt64>(spec.tv_sec)) + (AuUInt64)spec.tv_nsec;
}
#endif
return std::chrono::duration_cast<std::chrono::nanoseconds>(high_res_clock::now().time_since_epoch()).count();
}
@ -328,7 +338,7 @@ namespace Aurora::Time
#if defined(AURORA_IS_POSIX_DERIVED)
::timespec spec {};
if (::clock_getres(CLOCK_MONOTONIC, &spec) == 0)
if (::clock_getres(CLOCK_PROCESS_CPUTIME_ID, &spec) == 0)
{
if (spec.tv_nsec && !spec.tv_sec)
{