[*] further deprecate high res clock
[*] further posix resolution reporting
This commit is contained in:
parent
945d54ef78
commit
2a33d61e63
@ -85,58 +85,53 @@ namespace Aurora::Time
|
|||||||
AUKN_SYM AuUInt64 SteadyClockJiffies();
|
AUKN_SYM AuUInt64 SteadyClockJiffies();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief frequency
|
* @brief frequency in jiffies per second
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
AUKN_SYM AuUInt64 ThreadClockJiffies();
|
AUKN_SYM AuUInt64 ThreadClockJiffies();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief time spent in userspace under this context [in jiffies]
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
AUKN_SYM AuUInt64 ThreadClock();
|
AUKN_SYM AuUInt64 ThreadClock();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief time spent in userspace under this context
|
* @brief time spent in userspace under this context [in nanoseconds]
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
AUKN_SYM AuUInt64 ThreadClockNS();
|
AUKN_SYM AuUInt64 ThreadClockNS();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief time spent in userspace under this context [in milliseconds]
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
AUKN_SYM AuUInt64 ThreadClockMS();
|
AUKN_SYM AuUInt64 ThreadClockMS();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief frequency
|
* @brief frequency in jiffies per second
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
AUKN_SYM AuUInt64 ProcessClockJiffies();
|
AUKN_SYM AuUInt64 ProcessClockJiffies();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief time spent in userspace and in the kernel under this process
|
* @brief time spent in userspace and in the kernel under this process [in jiffies]
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
AUKN_SYM AuUInt64 ProcessClock();
|
AUKN_SYM AuUInt64 ProcessClock();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief time spent in userspace and in the kernel under this process [in nanoseconds]
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
AUKN_SYM AuUInt64 ProcessClockNS();
|
AUKN_SYM AuUInt64 ProcessClockNS();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief time spent in userspace and in the kernel under this process [in milliseconds]
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
AUKN_SYM AuUInt64 ProcessClockMS();
|
AUKN_SYM AuUInt64 ProcessClockMS();
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Returns a high resolution count of jiffies with an undefined epoch from a
|
|
||||||
high resolution clock.
|
|
||||||
|
|
||||||
These values should be used to drive benchmarks.
|
|
||||||
These values should not nor can be accurately converted meaningfully
|
|
||||||
*/
|
|
||||||
AUKN_SYM AuUInt64 HighResClock();
|
|
||||||
AUKN_SYM AuUInt64 HighResClockMS();
|
|
||||||
AUKN_SYM AuUInt64 HighResClockNS();
|
|
||||||
|
|
||||||
/**
|
|
||||||
Retrieves the freqency of jiffies per second
|
|
||||||
*/
|
|
||||||
AUKN_SYM AuUInt64 HighResClockJiffies();
|
|
||||||
|
|
||||||
/**
|
|
||||||
Let's say you're fucked and you need a ball park figure.
|
|
||||||
Enjoy...
|
|
||||||
*/
|
|
||||||
AUKN_SYM AuUInt64 ConvertInternalToAuroraEpochMS(AuUInt64 in);
|
|
||||||
AUKN_SYM AuUInt64 ConvertInternalToAuroraEpochNS(AuUInt64 in);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Converts seconds from the Aurora epoch to time_t
|
Converts seconds from the Aurora epoch to time_t
|
||||||
*/
|
*/
|
||||||
@ -154,16 +149,6 @@ namespace Aurora::Time
|
|||||||
|
|
||||||
AUKN_SYM AuInt64 CTimeToMS(time_t time);
|
AUKN_SYM AuInt64 CTimeToMS(time_t time);
|
||||||
|
|
||||||
/**
|
|
||||||
Retrieves the freqency as a fraction of: jiffies per second / 1 * nanoseconds in a second
|
|
||||||
*/
|
|
||||||
AUKN_SYM double CPUFrequencyDeltaNS();
|
|
||||||
|
|
||||||
/**
|
|
||||||
Retrieves the freqency as a fraction of: jiffies per second / 1 * milliseconds in a second
|
|
||||||
*/
|
|
||||||
AUKN_SYM double CPUFrequencyDeltaMS();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
* @return
|
* @return
|
||||||
|
@ -468,7 +468,7 @@ namespace Aurora::IO
|
|||||||
if (this->IsTickOnly())
|
if (this->IsTickOnly())
|
||||||
{
|
{
|
||||||
auto next = this->timers.nbTicker.nextTriggerTime;
|
auto next = this->timers.nbTicker.nextTriggerTime;
|
||||||
auto now = AuTime::HighResClockNS();
|
auto now = AuTime::SteadyClockNS();
|
||||||
|
|
||||||
if (now >= next)
|
if (now >= next)
|
||||||
{
|
{
|
||||||
@ -607,7 +607,7 @@ namespace Aurora::IO
|
|||||||
|
|
||||||
if (!this->timers.nbTicker.nextTriggerTime)
|
if (!this->timers.nbTicker.nextTriggerTime)
|
||||||
{
|
{
|
||||||
this->timers.nbTicker.nextTriggerTime = AuTime::HighResClockNS() + this->timers.nbTicker.nsTimeStep;
|
this->timers.nbTicker.nextTriggerTime = AuTime::SteadyClockNS() + this->timers.nbTicker.nsTimeStep;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -591,7 +591,7 @@ namespace Aurora::IO::Loop
|
|||||||
|
|
||||||
count = this->handleArrayAnd_.size();
|
count = this->handleArrayAnd_.size();
|
||||||
|
|
||||||
AuUInt64 startTime = AuTime::HighResClockMS();
|
AuUInt64 startTime = AuTime::SteadyClockMS();
|
||||||
AuUInt64 endTime = startTime + timeout;
|
AuUInt64 endTime = startTime + timeout;
|
||||||
|
|
||||||
for (const auto &source : this->loopSourceExs_)
|
for (const auto &source : this->loopSourceExs_)
|
||||||
@ -603,7 +603,7 @@ namespace Aurora::IO::Loop
|
|||||||
{
|
{
|
||||||
auto next = AuMin(count - index, AuUInt32(MAXIMUM_WAIT_OBJECTS));
|
auto next = AuMin(count - index, AuUInt32(MAXIMUM_WAIT_OBJECTS));
|
||||||
|
|
||||||
startTime = AuTime::HighResClockMS();
|
startTime = AuTime::SteadyClockMS();
|
||||||
|
|
||||||
if (timeout)
|
if (timeout)
|
||||||
{
|
{
|
||||||
@ -729,7 +729,7 @@ namespace Aurora::IO::Loop
|
|||||||
AuUInt32 ret {};
|
AuUInt32 ret {};
|
||||||
bool lastItr {};
|
bool lastItr {};
|
||||||
|
|
||||||
AuUInt64 startTime = AuTime::HighResClockMS();
|
AuUInt64 startTime = AuTime::SteadyClockNS();
|
||||||
AuUInt64 endTime = timeout ? (startTime + timeout) : AuUInt64(-1);
|
AuUInt64 endTime = timeout ? (startTime + timeout) : AuUInt64(-1);
|
||||||
AuUInt32 chuggerIndex {};
|
AuUInt32 chuggerIndex {};
|
||||||
|
|
||||||
@ -751,7 +751,7 @@ namespace Aurora::IO::Loop
|
|||||||
{
|
{
|
||||||
AuList<AuSPtr<ILoopSource>> trigger;
|
AuList<AuSPtr<ILoopSource>> trigger;
|
||||||
|
|
||||||
AuUInt64 startTime = AuTime::HighResClockMS();
|
AuUInt64 startTime = AuTime::SteadyClockNS();
|
||||||
AuUInt64 endTime = timeout ? (startTime + timeout) : AuUInt64(-1);
|
AuUInt64 endTime = timeout ? (startTime + timeout) : AuUInt64(-1);
|
||||||
AuUInt32 chuggerIndex {};
|
AuUInt32 chuggerIndex {};
|
||||||
|
|
||||||
@ -827,7 +827,7 @@ namespace Aurora::IO::Loop
|
|||||||
auto sleepMS = this->slowTickMs_;
|
auto sleepMS = this->slowTickMs_;
|
||||||
if (internalEndTime && internalEndTime != AuUInt64(-1))
|
if (internalEndTime && internalEndTime != AuUInt64(-1))
|
||||||
{
|
{
|
||||||
auto now = AuTime::HighResClockMS();
|
auto now = AuTime::SteadyClockMS();
|
||||||
auto delta = AuInt64(internalEndTime) - AuInt64(now);
|
auto delta = AuInt64(internalEndTime) - AuInt64(now);
|
||||||
|
|
||||||
if (delta <= 0)
|
if (delta <= 0)
|
||||||
@ -920,7 +920,7 @@ namespace Aurora::IO::Loop
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto now = AuTime::HighResClockMS();
|
auto now = AuTime::SteadyClockMS();
|
||||||
if (internalEndTime <= now)
|
if (internalEndTime <= now)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -982,7 +982,7 @@ namespace Aurora::IO::Loop
|
|||||||
{
|
{
|
||||||
Iterator queueIterator(this);
|
Iterator queueIterator(this);
|
||||||
AuSInt indexOffset {};
|
AuSInt indexOffset {};
|
||||||
auto now = AuTime::HighResClockMS();
|
auto now = AuTime::SteadyClockMS();
|
||||||
for (queueIterator.Start(); queueIterator.End() != queueIterator.itr; )
|
for (queueIterator.Start(); queueIterator.End() != queueIterator.itr; )
|
||||||
{
|
{
|
||||||
bool shouldRemove {false};
|
bool shouldRemove {false};
|
||||||
@ -1254,7 +1254,7 @@ namespace Aurora::IO::Loop
|
|||||||
Iterator queueIterator(this);
|
Iterator queueIterator(this);
|
||||||
bool bRebuildFromAnd {};
|
bool bRebuildFromAnd {};
|
||||||
|
|
||||||
auto now = AuTime::HighResClockMS();
|
auto now = AuTime::SteadyClockMS();
|
||||||
for (queueIterator.Start(); queueIterator.End() != queueIterator.itr; )
|
for (queueIterator.Start(); queueIterator.End() != queueIterator.itr; )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ namespace Aurora::Threading::Primitives
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AuUInt64 startTime = AuTime::HighResClockNS();
|
AuUInt64 startTime = AuTime::SteadyClockNS();
|
||||||
AuUInt64 endTime = startTime + timeout;
|
AuUInt64 endTime = startTime + timeout;
|
||||||
|
|
||||||
while (AuAtomicTestAndSet(&this->state_, 0))
|
while (AuAtomicTestAndSet(&this->state_, 0))
|
||||||
@ -72,7 +72,7 @@ namespace Aurora::Threading::Primitives
|
|||||||
long count = 0;
|
long count = 0;
|
||||||
while (this->state_)
|
while (this->state_)
|
||||||
{
|
{
|
||||||
if (endTime <= AuTime::HighResClockNS())
|
if (endTime <= AuTime::SteadyClockNS())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -130,6 +130,12 @@ static time_t CalculateTimeT(AuUInt64 in)
|
|||||||
|
|
||||||
namespace Aurora::Time
|
namespace Aurora::Time
|
||||||
{
|
{
|
||||||
|
// removed from public header / deprecating
|
||||||
|
AUKN_SYM AuUInt64 HighResClock();
|
||||||
|
AUKN_SYM AuUInt64 HighResClockNS();
|
||||||
|
AUKN_SYM AuUInt64 HighResClockMS();
|
||||||
|
AUKN_SYM AuUInt64 HighResClockJiffies();
|
||||||
|
|
||||||
AUKN_SYM time_t SToCTime(AuInt64 time)
|
AUKN_SYM time_t SToCTime(AuInt64 time)
|
||||||
{
|
{
|
||||||
return CalculateTimeT<std::chrono::seconds>(time);
|
return CalculateTimeT<std::chrono::seconds>(time);
|
||||||
@ -262,6 +268,22 @@ namespace Aurora::Time
|
|||||||
return 1000000000ull / 100u;
|
return 1000000000ull / 100u;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(AURORA_IS_POSIX_DERIVED)
|
||||||
|
::timespec spec {};
|
||||||
|
if (::clock_getres(CLOCK_THREAD_CPUTIME_ID, &spec) == 0)
|
||||||
|
{
|
||||||
|
if (spec.tv_nsec && !spec.tv_sec)
|
||||||
|
{
|
||||||
|
return frequency = 1000000000ull / spec.tv_nsec;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SysUnreachable();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return HighResClockJiffies();
|
return HighResClockJiffies();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,6 +355,22 @@ namespace Aurora::Time
|
|||||||
return 1000000000ull / 100u;
|
return 1000000000ull / 100u;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(AURORA_IS_POSIX_DERIVED)
|
||||||
|
::timespec spec {};
|
||||||
|
if (::clock_getres(CLOCK_PROCESS_CPUTIME_ID, &spec) == 0)
|
||||||
|
{
|
||||||
|
if (spec.tv_nsec && !spec.tv_sec)
|
||||||
|
{
|
||||||
|
return frequency = 1000000000ull / spec.tv_nsec;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SysUnreachable();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return HighResClockJiffies();
|
return HighResClockJiffies();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,26 +418,6 @@ namespace Aurora::Time
|
|||||||
return epochDelta + in;
|
return epochDelta + in;
|
||||||
}
|
}
|
||||||
|
|
||||||
AUKN_SYM double CPUFrequencyDeltaNS()
|
|
||||||
{
|
|
||||||
static double frequency = 0;
|
|
||||||
if (frequency != 0)
|
|
||||||
{
|
|
||||||
return frequency;
|
|
||||||
}
|
|
||||||
return frequency = (static_cast<double>(high_res_clock::period::num) / static_cast<double>(high_res_clock::period::den) * 1'000'000'000.f);
|
|
||||||
}
|
|
||||||
|
|
||||||
AUKN_SYM double CPUFrequencyDeltaMS()
|
|
||||||
{
|
|
||||||
static double frequency = 0;
|
|
||||||
if (frequency != 0)
|
|
||||||
{
|
|
||||||
return frequency;
|
|
||||||
}
|
|
||||||
return frequency = (static_cast<double>(high_res_clock::period::num) / static_cast<double>(high_res_clock::period::den) * 1'000.f);
|
|
||||||
}
|
|
||||||
|
|
||||||
AUKN_SYM AuUInt64 SteadyClockJiffies()
|
AUKN_SYM AuUInt64 SteadyClockJiffies()
|
||||||
{
|
{
|
||||||
static AuUInt64 frequency = 0;
|
static AuUInt64 frequency = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user