当前位置: 首页>>代码示例>>C++>>正文


C++ TimeUnit::count方法代码示例

本文整理汇总了C++中TimeUnit::count方法的典型用法代码示例。如果您正苦于以下问题:C++ TimeUnit::count方法的具体用法?C++ TimeUnit::count怎么用?C++ TimeUnit::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TimeUnit的用法示例。


在下文中一共展示了TimeUnit::count方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getElapsed

	// TODO: USE idx INSTEAD OF size_t
    size_t getElapsed()
    {
	/*!
	* Returns elapsed time as number of ticks of TimeUnits
	* Elapsed time can mean 2 different things:
	* 
	* 1. 	If TickCounter is running, elapsed time is measured between starTime
	* 	and now.
	* 2. 	If TickCounter is not running (i.e. it is stopped), elapsed time
	* 	is measured between startTime and stopTime.
	*/
      
		// DIFFERENCE BETWEEN THE TWO "TIMEPOINTS" MUST BE CAST TO
		// A "DURATION" USING THE std::chrono::duration_cast 
		TimeUnit duration;
	
		// CASE 1 - TickCounter IS RUNNING, USE CURRENT TIME
		if (isRunning)
		{
			duration = std::chrono::duration_cast <TimeUnit> 
			( std::chrono::high_resolution_clock::now() - startTime );
		}
		// CASE 2 - NOT RUNNING, USE stopTime
		else
		{
			duration = std::chrono::duration_cast<TimeUnit> 
			(stopTime - startTime);
		}
		// CAST TO TICK COUNT
		return static_cast <size_t> ( duration.count() );
    }
开发者ID:erwi,项目名称:SpaMtrix,代码行数:32,代码来源:spamtrix_tickcounter.hpp


注:本文中的TimeUnit::count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。