[英]c++ boost calculate time spent in function
再次問一個提升問題:我需要在我的提升線程中計算在 function 中花費的時間:這是代碼:
boost::posix_time::microseconds tes( 12 );
int i = 0;
while( true )
{
boost::posix_time::ptime start = boost::posix_time::microsec_clock::local_time( );
myFunction( );
boost::this_thread::sleep( tes );
boost::posix_time::ptime end = boost::posix_time::microsec_clock::local_time( );
boost::posix_time::time_duration elapsed = end - start;
}
所以我嘗試了很多次,但經過的 time_duration 始終為 0,我添加了測試 12 微秒的睡眠 function,所以最好的方法是我將經過 12 微秒但仍然為 0 .. 我需要告訴線程讀取時間后更新計時器?
謝謝
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.