本文整理汇总了C++中TimeSpan::TotalMilliseconds方法的典型用法代码示例。如果您正苦于以下问题:C++ TimeSpan::TotalMilliseconds方法的具体用法?C++ TimeSpan::TotalMilliseconds怎么用?C++ TimeSpan::TotalMilliseconds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeSpan
的用法示例。
在下文中一共展示了TimeSpan::TotalMilliseconds方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VerifyContent
void CachedFileTest::VerifyContent(wstring const & expectedContent, TimeSpan const & waitTimeMax)
{
TimeSpan waitTime = TimeSpan::Zero;
TimeSpan retryDelay = TimeSpan::FromMilliseconds(300);
for(;;)
{
wstring actualContent = L"";
ReadFromCache(actualContent);
if (actualContent == expectedContent)
{
break;
}
waitTime = waitTime + retryDelay;
if (waitTime > waitTimeMax)
{
FAIL_TEST(
"Actual Content '{0}' does not match expected Content '{1}'",
actualContent,
expectedContent);
}
else
{
Trace.WriteInfo(
TraceType,
"Sleep to wait for notifications to be processed");
Sleep(static_cast<DWORD>(retryDelay.TotalMilliseconds()));
}
}
}
示例2: Update
void DecayAverage::Update(TimeSpan const & value)
{
uint millisecondsValue;
StopwatchTime now = Stopwatch::Now();
if (value.TotalMilliseconds() > MAX_VALUE)
{
millisecondsValue = MAX_VALUE;
}
else
{
millisecondsValue = static_cast<uint>(value.TotalMilliseconds());
}
if (decayFactor_ == 0.0)
{
weightedSumMilliSeconds_ = static_cast<double>(millisecondsValue);
sumOfWeightMilliSeconds_ = 1.0;
}
else
{
TimeSpan interval = now - lastUpdatedTime_;
double power = interval / decayInterval_;
double coefficient = pow(decayFactor_, power);
if (coefficient > MinCoefficient &&
MAX_DOUBLE - weightedSumMilliSeconds_ > millisecondsValue) // Protect against overflow here
{
weightedSumMilliSeconds_ = weightedSumMilliSeconds_ * coefficient + static_cast<double>(millisecondsValue);
sumOfWeightMilliSeconds_ = sumOfWeightMilliSeconds_ * coefficient + 1.0;
}
else
{
weightedSumMilliSeconds_ = static_cast<double>(millisecondsValue);
sumOfWeightMilliSeconds_ = 1.0;
}
}
lastValueMilliSeconds_ = millisecondsValue;
lastUpdatedTime_ = now;
}
示例3: Sleep
/**
* Signals the current thread to stop processing for the specified time span.
*
* @param timeSpan The amount of time to stop processing.
*/
static void Sleep(const TimeSpan& timeSpan) { StackTrace trace(__METHOD__, __FILE__, __LINE__);
if (timeSpan > TimeSpan::Zero()) {
msleep((uint32_t) timeSpan.TotalMilliseconds());
Idle += timeSpan;
}
}
示例4: Utilization
/**
* Returns the thread utilization.
*
* @return A value in between zero and one, where zero means the thread was completely idle, and one means the thread was completely busy.
*/
static double Utilization() { StackTrace trace(__METHOD__, __FILE__, __LINE__);
double duration = (DateTime::Utc() - Started).TotalMilliseconds();
return (duration - Idle.TotalMilliseconds()) / duration;
}