本文整理汇总了C++中boost::timer::restart方法的典型用法代码示例。如果您正苦于以下问题:C++ timer::restart方法的具体用法?C++ timer::restart怎么用?C++ timer::restart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::timer
的用法示例。
在下文中一共展示了timer::restart方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
});
}
示例2: route
/// \brief Primary route call.
void route(RouteNet& inNet) {
mRouteTimer.restart();
routeNet(inNet);
double routeTime = mRouteTimer.elapsed();
mTotalRouteTime += routeTime;
inNet.mProperties[eRouteTime] = routeTime;
}
示例3: 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( );
}
}
示例4: 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);
}
示例5: 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);
}
示例6: 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_;
}
示例7: 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);
}
}
示例8: reportStart
virtual void reportStart() {
timer.restart();
customStart();
}
示例9: VideoInputFrameArrived
virtual HRESULT STDMETHODCALLTYPE VideoInputFrameArrived(IDeckLinkVideoInputFrame* video, IDeckLinkAudioInputPacket* audio)
{
if(!video)
return S_OK;
try
{
graph_->set_value("tick-time", tick_timer_.elapsed()*format_desc_.fps*0.5);
tick_timer_.restart();
frame_timer_.restart();
// PUSH
void* bytes = nullptr;
if(FAILED(video->GetBytes(&bytes)) || !bytes)
return S_OK;
safe_ptr<AVFrame> av_frame(avcodec_alloc_frame(), av_free);
avcodec_get_frame_defaults(av_frame.get());
av_frame->data[0] = reinterpret_cast<uint8_t*>(bytes);
av_frame->linesize[0] = video->GetRowBytes();
av_frame->format = PIX_FMT_UYVY422;
av_frame->width = video->GetWidth();
av_frame->height = video->GetHeight();
av_frame->interlaced_frame = format_desc_.field_mode != core::field_mode::progressive;
av_frame->top_field_first = format_desc_.field_mode == core::field_mode::upper ? 1 : 0;
std::shared_ptr<core::audio_buffer> audio_buffer;
// It is assumed that audio is always equal or ahead of video.
if(audio && SUCCEEDED(audio->GetBytes(&bytes)) && bytes)
{
auto sample_frame_count = audio->GetSampleFrameCount();
auto audio_data = reinterpret_cast<int32_t*>(bytes);
audio_buffer = std::make_shared<core::audio_buffer>(audio_data, audio_data + sample_frame_count*format_desc_.audio_channels);
}
else
audio_buffer = std::make_shared<core::audio_buffer>(audio_cadence_.front(), 0);
// Note: Uses 1 step rotated cadence for 1001 modes (1602, 1602, 1601, 1602, 1601)
// This cadence fills the audio mixer most optimally.
sync_buffer_.push_back(audio_buffer->size());
if(!boost::range::equal(sync_buffer_, audio_cadence_))
{
CASPAR_LOG(trace) << print() << L" Syncing audio.";
return S_OK;
}
muxer_.push(audio_buffer);
muxer_.push(av_frame, hints_);
boost::range::rotate(audio_cadence_, std::begin(audio_cadence_)+1);
// POLL
for(auto frame = muxer_.poll(); frame; frame = muxer_.poll())
{
if(!frame_buffer_.try_push(make_safe_ptr(frame)))
{
auto dummy = core::basic_frame::empty();
frame_buffer_.try_pop(dummy);
frame_buffer_.try_push(make_safe_ptr(frame));
graph_->set_tag("dropped-frame");
}
}
graph_->set_value("frame-time", frame_timer_.elapsed()*format_desc_.fps*0.5);
graph_->set_value("output-buffer", static_cast<float>(frame_buffer_.size())/static_cast<float>(frame_buffer_.capacity()));
}
catch(...)
{
exception_ = std::current_exception();
return E_FAIL;
}
return S_OK;
}
示例10: restart
void restart() { t.restart(); }