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


C++ timer::elapsed方法代码示例

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


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

示例1: send

	virtual boost::unique_future<bool> send(const safe_ptr<core::read_frame>& frame) override
	{
		CASPAR_VERIFY(format_desc_.height * format_desc_.width * 4 == static_cast<unsigned>(frame->image_data().size()));

		return executor_.begin_invoke([=]() -> bool
		{			
			graph_->set_value("tick-time", tick_timer_.elapsed() * format_desc_.fps * 0.5);
			tick_timer_.restart();
			frame_timer_.restart();

			// AUDIO

			std::vector<int16_t, tbb::cache_aligned_allocator<int16_t>> audio_buffer;

			if (core::needs_rearranging(
					frame->multichannel_view(),
					channel_layout_,
					channel_layout_.num_channels))
			{
				core::audio_buffer downmixed;

				downmixed.resize(
						frame->multichannel_view().num_samples() 
								* channel_layout_.num_channels,
						0);

				auto dest_view = core::make_multichannel_view<int32_t>(
						downmixed.begin(), downmixed.end(), channel_layout_);

				core::rearrange_or_rearrange_and_mix(
						frame->multichannel_view(),
						dest_view,
						core::default_mix_config_repository());

				audio_buffer = core::audio_32_to_16(downmixed);
			}
			else
			{
				audio_buffer = core::audio_32_to_16(frame->audio_data());
			}

			airsend::add_audio(air_send_.get(), audio_buffer.data(), audio_buffer.size() / channel_layout_.num_channels);

			// VIDEO

			connected_ = airsend::add_frame_bgra(air_send_.get(), frame->image_data().begin());

			graph_->set_text(print());
			graph_->set_value("frame-time", frame_timer_.elapsed() * format_desc_.fps * 0.5);
			
			return true;
		});
	}
开发者ID:GamingAtheist,项目名称:Server,代码行数:53,代码来源:newtek_ivga_consumer.cpp

示例2: route

		/// \brief Primary route call.
		void route(RouteNet& inNet) {
			mRouteTimer.restart();
			routeNet(inNet);
			double routeTime = mRouteTimer.elapsed();
			mTotalRouteTime += routeTime;
			inNet.mProperties[eRouteTime] = routeTime;
		}
开发者ID:torc-isi,项目名称:torc,代码行数:8,代码来源:NetRouterBase.hpp

示例3: OnTimer

void CMainDlg::OnTimer(UINT_PTR nIDEvent)
{
	if (nIDEvent == 1 && gStop)
	{
		static boost::timer tmr;
		// 延迟3秒关闭
		if (tmr.elapsed() > 3)
		{
			// 检测关闭
			trayIcon.Hide();
			CloseDialog(0);
			TerminateProcess(GetCurrentProcess(), 0);
		}
	}
	else if (nIDEvent == 2 && exiting && !gStop)
	{
		static int times = 0;
		if (times < 3)
		{
			times++;
			// L"正在退出太一,请稍候.."
			trayIcon.SetBalloonDetails(GetLocalWStr(strTrayNowExiting), L"", CTrayNotifyIcon::None, 100);
		}
	}
	else
	{
		SetMsgHandled(false);
	}
}
开发者ID:lcfGitHubCode,项目名称:TaiyiCode,代码行数:29,代码来源:MainDlg.cpp

示例4: get_and_record_age_millis

	int64_t get_and_record_age_millis()
	{
		if (recorded_frame_age_ == -1)
			recorded_frame_age_ = static_cast<int64_t>(
					since_created_timer_.elapsed() * 1000.0);

		return recorded_frame_age_;
	}
开发者ID:AKinanS,项目名称:Server,代码行数:8,代码来源:write_frame.cpp

示例5: sufficient_time

bool sufficient_time()
{
   // return true if enough time has passed since the tests began:
   static boost::static_mutex mut = BOOST_STATIC_MUTEX_INIT ;
   boost::static_mutex::scoped_lock guard(mut);
   static boost::timer t;
   // is 10 seconds enough?
   return t.elapsed() >= 10.0;
}
开发者ID:hoangphihung0604,项目名称:boost,代码行数:9,代码来源:static_mutex_test.cpp

示例6: wait_idle_time

 void Reconstruct::wait_idle_time( boost::timer& timer, int idle_time )
 {
     timer.restart( );
     while( boost::posix_time::seconds( timer.elapsed( ) ) < boost::posix_time::milliseconds( idle_time ) && !m_abort_scan )
     {
         boost::this_thread::sleep( boost::posix_time::milliseconds( 1 ) );
         QApplication::processEvents( );
     }
 }
开发者ID:Gombat,项目名称:bla3Dscan,代码行数:9,代码来源:reconstruct.cpp

示例7: testQuickSort

float testQuickSort(int vectorSize, int numberOfIterations)
{
	vector<int> quick;
	quick.reserve(vectorSize);
	float elapsedTime = 0;

	for (int iterations = 0; iterations < numberOfIterations; ++iterations)
	{
		quick = fillVectorWithRandomInts(quick.size());
		testTimer.restart();
		quick = sorter.quickSort(quick);
		elapsedTime += testTimer.elapsed();
	}
	return (elapsedTime / numberOfIterations);
}
开发者ID:DuxClarus,项目名称:Uat-Portfolio,代码行数:15,代码来源:Driver.cpp

示例8: testInsertionSort

float testInsertionSort(int vectorSize, int numberOfIterations)
{
	vector<int> insertion;
	insertion.reserve(vectorSize);
	float elapsedTime = 0;

	for (int iterations = 0; iterations < numberOfIterations; ++iterations)
	{
		insertion = fillVectorWithRandomInts(insertion.size());
		testTimer.restart();
		insertion = sorter.insertionSort(insertion);
		elapsedTime += testTimer.elapsed();
	}
	return (elapsedTime / numberOfIterations);
}
开发者ID:DuxClarus,项目名称:Uat-Portfolio,代码行数:15,代码来源:Driver.cpp

示例9: OnGetData

	virtual bool OnGetData(sf::SoundStream::Chunk& data) override
	{		
		win32_exception::ensure_handler_installed_for_thread(
				"sfml-audio-thread");
		std::pair<std::shared_ptr<core::read_frame>, std::shared_ptr<audio_buffer_16>> audio_data;

		input_.pop(audio_data); // Block until available

		graph_->set_value("tick-time", perf_timer_.elapsed()*format_desc_.fps*0.5);		
		perf_timer_.restart();

		container_.push_back(std::move(*audio_data.second));
		data.Samples = container_.back().data();
		data.NbSamples = container_.back().size();	
		

		if (audio_data.first)
			presentation_age_ = audio_data.first->get_age_millis();

		return is_running_;
	}
开发者ID:AurelienRevault,项目名称:Caspar-Server,代码行数:21,代码来源:oal_consumer.cpp

示例10: run_test

void run_test(int NUM_TESTS, std::vector<int> NUM_POINTS, std::vector<int> NUM_RUNS) {
    for (int i = 0; i < NUM_TESTS; ++i) {

        kdtree::KDTree<Point> tr(2);
        for(int k=0; k<NUM_POINTS[i]; k++) {
            double x = ((float)rand() / RAND_MAX) * 200.0 - 100.0;
            double y = ((float)rand() / RAND_MAX) * 200.0 - 100.0;
            Point p(x,y);
            tr.insert( p );
        }
    
        timer.restart();
        for (int j = 0; j < NUM_RUNS[i]; ++j) {
            double x = ((float)rand() / RAND_MAX) * 200.0 - 100.0;
            double y = ((float)rand() / RAND_MAX) * 200.0 - 100.0;
            Point ps(x,y);
            std::pair<Point,double> pt = tr.nearest( ps );
        }
        double total_time = timer.elapsed();
        double time_per_test = total_time / NUM_RUNS[i];
        format_line(NUM_POINTS[i], NUM_RUNS[i], total_time, time_per_test);
    }
}
开发者ID:aewallin,项目名称:sandbox,代码行数:23,代码来源:bench.cpp

示例11: elapsed

	double elapsed()	{ return t.elapsed() * 1000.0; }
开发者ID:Aldude,项目名称:Leroy-Jenkins-Bot,代码行数:1,代码来源:OldTimer.hpp

示例12:

            ~bench_atomic() {
			    threads.join_all();
                std::cerr << "bench_atomic: x = " << x << ", elapsed time is " << timer.elapsed()
                          << "\n";
		    }
开发者ID:drednout,项目名称:cpp_bench,代码行数:5,代码来源:main.cpp

示例13: Execute

std::string StartGate::Execute()
{
    static boost::timer _timestamp;
    std::cout << "===========================================================" << std::endl;
    std::cout << "State: " << ID << "::" << GetStateName(mState) << "\tTime: " << _timestamp.elapsed() << std::endl;
    std::cout << std::endl;

    bool pathExists = false;
    std::vector<Path> paths;

    switch (mState)
    {
        case GoToDepth:

            mDesiredYaw = mStartYaw;
            mDesiredDepth = mInitDepth;

            if(fabs(AI::Utility::DepthDiff(mCurrentDepth, mInitDepth)) < mDepthThresh && fabs(Zebulon::AI::Utility::AngleDiff(mCurrentYaw, mStartYaw)) <= mYawThresh)
            {

                mInitTravel.Start();
                mState = InitTravel;
            }

            break;

        case InitTravel:

            mDesiredYaw = mStartYaw;
            mDesiredDepth = mInitDepth;
            mDesiredAxialThrust = mInitTravelSpeed;

            if(mInitTravel.IsFinished())
            {
                mPathTravel.Start();
                mState = PathTravel;
            }

            std::cout << " \tDesired:\tCurrent:\tDiff" << std::endl;
            std::cout << "Timer:"
                      << "\t" << mInitTravel.GetRunTime()
                      << "\t" << mInitTravel.TimeElapsed()
                      << "\t" << mInitTravel.GetRunTime()-mInitTravel.TimeElapsed()
                      << std::endl;

            break;

        case PathTravel:

            mDesiredYaw = mStartYaw;
            mDesiredDepth = mInitDepth;
            mDesiredAxialThrust = mPathTravelSpeed;

            pathExists = GetPaths(paths , mCurrentYaw, mDWFrame, mDWProcFrame);


            if(mPathTravel.IsFinished() || pathExists == true)
            {
                mState = LeaveMission;
            }

            std::cout << " \tDesired:\tCurrent:\tDiff" << std::endl;
            std::cout << "Timer:"
                      << "\t" << mPathTravel.GetRunTime()
                      << "\t" << mPathTravel.TimeElapsed()
                      << "\t" << mPathTravel.GetRunTime()-mPathTravel.TimeElapsed()
                      << std::endl;

            break;

        case LeaveMission:

            if(mLeaveMission == false)
            {
                mGlobalInfo->SetInfo(GlobalInfo::FixedYaw,mStartYaw);
                //mGlobalInfo->SetInfo(GlobalInfo::StartYaw,mStartYaw);
                Utility::Display::CloseAllWindows();
                mLeaveMission = true;
            }

            return NextMission;

            break;

        default:

            std::cout << "ERROR::" << ID << " state " << mState << " does not exist!" << std::endl;

            break;

    }

    //if (mState == PathTravel)
    {
        AI::Utility::HeadingDisplay(mDWProcFrame, mCurrentYaw, mDesiredYaw, 0, 255, 255);
        AI::Utility::DepthDisplay(mDWProcFrame, mCurrentDepth, mDesiredDepth, 0, 192);
        AI::Utility::ThrustDisplay(mDWProcFrame, mDesiredAxialThrust, mDesiredLateralThrust);

        Utility::Display::DisplayImage("DW Frame",mDWFrame);
        Utility::Display::DisplayImage("Processed DW Frame",mDWProcFrame);
//.........这里部分代码省略.........
开发者ID:ShowLove,项目名称:Robotics_Club,代码行数:101,代码来源:startgate.cpp

示例14: elapsed

		double elapsed(){return t_.elapsed();}
开发者ID:Alchoran,项目名称:MafiaBot,代码行数:1,代码来源:timer.hpp

示例15: Execute

std::string EtTuBrute::Execute()
{
    static boost::timer _timestamp;
    std::cout << "===========================================================" << std::endl;
    std::cout << "State: " << ID << "::" << GetStateName(mState) << "\tTime: " << _timestamp.elapsed() << " " << mStateTimeout.TimeElapsed() << std::endl;
    std::cout << std::endl;

    bool pathExists = false;
    std::vector<Path> paths;

    switch (mState)
    {
        // Go to Path Depth, leave immediatley if path is found
        case GoToPathDepth:

            mDesiredYaw = mFixedYaw;
            mDesiredDepth = mPathDepth;
            mDesiredAxialThrust = 0;
            mDesiredLateralThrust = 0;

            pathExists = GetPaths(paths, mCurrentYaw, mDWFrame, mDWProcFrame);


            if((fabs(AI::Utility::DepthDiff(mCurrentDepth, mPathDepth)) < mDepthThresh
                && fabs(Zebulon::AI::Utility::AngleDiff(mCurrentYaw, mFixedYaw)) <= mYawThresh))
                // Add a check if the path is seen to go directly to path found ... || )
            {

                mPathSearchTimer.Start();
                InitSearch();
                mState = PathSearch;
            }

            break;

        //Search for a path, if found center, if not timeout and look at buoys
        case PathSearch:

            mDesiredYaw = mFixedYaw;
            mDesiredDepth = mPathDepth;
            mDesiredAxialThrust = 0;
            mDesiredLateralThrust = 0;

            pathExists = GetPaths(paths, mCurrentYaw, mDWFrame, mDWProcFrame);
            //Add some kind of debouncing to get here, in fetch probably
            if(pathExists)
            {
                mState = DoPath;
            }
            else if(mPathSearchTimer.IsFinished())
            {
                mState = GoToObstacleDepth;
            }
            else
            {
                SearchStep();
                //mPathSearchPattern.SearchStep(mDesiredLateralThrust, mDesiredAxialThrust);
            }

            std::cout << "Number of Paths: " << paths.size() << std::endl;

            std::cout << "Timer:"
                      << "\t" << mPathSearchTimer.GetRunTime()
                      << "\t" << mPathSearchTimer.TimeElapsed()
                      << "\t" << mPathSearchTimer.GetRunTime()-mPathSearchTimer.TimeElapsed()
                      << std::endl;

            break;

        //center in on a path
        case DoPath:

            //Don't debounce in DoPath
            GetPaths(paths, mCurrentYaw, mDWFrame, mDWProcFrame);
            if(paths.size()>0)
            {
                //if path is found change thrust
                if(mPathCenteredDebounce.Bounce(mPathFinder.StepPath(&paths[0], mCurrentYaw, mDesiredYaw, mDesiredAxialThrust, mDesiredLateralThrust)))
                {

                    mPathTimer.Initialize(mPathExitTime);
                    mPathTimer.Start();
                    //mFixedYaw = mDesiredYaw;
                    //mDesiredYaw = paths[0].mAngle;
                    mGlobalInfo->SetInfo(GlobalInfo::FixedYaw, mDesiredYaw);

                    cvCircle(mDWProcFrame, cvPoint(mDWProcFrame->width/2,mDWProcFrame->height/2), 200, cvScalar(0,255,0), 4);

                    mState = ExitPath;
                }
                else
                {
                    std::cout << "NOT CENTERED SEEN" << std::endl;
                    //mPathCenteredDebounce.Miss();
                }

                std::cout << "PATHS SEEN" << std::endl;
            }
            else
            {
//.........这里部分代码省略.........
开发者ID:ShowLove,项目名称:Robotics_Club,代码行数:101,代码来源:ettubrute.cpp


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