本文整理汇总了C++中ACE_High_Res_Timer::elapsed_microseconds方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_High_Res_Timer::elapsed_microseconds方法的具体用法?C++ ACE_High_Res_Timer::elapsed_microseconds怎么用?C++ ACE_High_Res_Timer::elapsed_microseconds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_High_Res_Timer
的用法示例。
在下文中一共展示了ACE_High_Res_Timer::elapsed_microseconds方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
int
Suspend_Resume_Test::svc ()
{
#if ACE_DEBUG_CST > 0
ACE_hthread_t thread_id;
ACE_Thread_Manager::instance ()->thr_self (thread_id);
ACE_DEBUG ((LM_DEBUG, "Suspend_Resume_Test::svc (), thread ID is %d\n",
thread_id));
#endif /* ACE_DEBUG_CST */
low_.ready ();
// For information: the cost of the just the loop itself below,
// without the suspend and resume calls, on a 166 MHz Ultrasparc
// is about 12.3 nanoseconds per iteration.
timer_.start ();
for (ACE_UINT32 i = 0; i < iterations_; ++i)
{
#if ACE_DEBUG_CST > 0
if (i % (iterations_ >= 10 ? iterations_ / 10 : 1) == 0)
ACE_DEBUG ((LM_DEBUG, "Suspend_Resume_Test::svc (), iteration %u\n",
i));
#endif /* ACE_DEBUG_CST */
if (ACE_OS::thr_suspend (low_.thread_id ()) != 0)
{
ACE_ERROR ((LM_ERROR, "%p\n", "thr_suspend"));
low_.done ();
return -1;
}
if (ACE_OS::thr_continue (low_.thread_id ()) != 0 &&
errno != EINVAL)
// EINVAL is OK: it just means that the thread needs to be joined.
{
ACE_ERROR ((LM_ERROR, "%p\n", "thr_continue"));
low_.done ();
return -1;
}
}
timer_.stop ();
timer_.elapsed_microseconds (elapsed_time_);
low_.done ();
#if ACE_DEBUG_CST > 0
ACE_DEBUG ((LM_DEBUG, "Suspend_Resume_Test::svc, finishing\n"));
#endif /* ACE_DEBUG_CST */
return 0;
}
示例2:
static
ACE_Time_Value
time_interval (const ACE_Time_Value &interval,
ACE_hrtime_t& nanoseconds,
ACE_hrtime_t& microseconds)
{
ACE_High_Res_Timer timer;
timer.start ();
ACE_OS::sleep (interval);
timer.stop ();
ACE_Time_Value measured;
timer.elapsed_time (measured);
timer.elapsed_time (nanoseconds);
timer.elapsed_microseconds (microseconds);
return measured;
}