本文整理汇总了C++中Stopwatch::get_seconds方法的典型用法代码示例。如果您正苦于以下问题:C++ Stopwatch::get_seconds方法的具体用法?C++ Stopwatch::get_seconds怎么用?C++ Stopwatch::get_seconds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stopwatch
的用法示例。
在下文中一共展示了Stopwatch::get_seconds方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write
bool MeshObjectWriter::write(
const MeshObject& object,
const char* object_name,
const char* filename)
{
assert(filename);
Stopwatch<DefaultWallclockTimer> stopwatch;
stopwatch.start();
try
{
GenericMeshFileWriter writer(filename);
MeshObjectWalker walker(object, object_name);
writer.write(walker);
}
catch (const exception& e)
{
RENDERER_LOG_ERROR(
"failed to write mesh file %s: %s.",
filename,
e.what());
return false;
}
stopwatch.measure();
RENDERER_LOG_INFO(
"wrote mesh file %s in %s.",
filename,
pretty_time(stopwatch.get_seconds()).c_str());
return true;
}
示例2: write_image
bool Frame::write_image(
const char* file_path,
const Image& image,
const ImageAttributes& image_attributes) const
{
assert(file_path);
Image final_image(image);
transform_to_output_color_space(final_image);
Stopwatch<DefaultWallclockTimer> stopwatch;
stopwatch.start();
try
{
try
{
GenericImageFileWriter writer;
writer.write(file_path, final_image, image_attributes);
}
catch (const ExceptionUnsupportedFileFormat&)
{
const string extension = lower_case(filesystem::path(file_path).extension());
RENDERER_LOG_ERROR(
"file format '%s' not supported, writing the image in OpenEXR format "
"(but keeping the filename unmodified).",
extension.c_str());
EXRImageFileWriter writer;
writer.write(file_path, final_image, image_attributes);
}
}
catch (const ExceptionIOError&)
{
RENDERER_LOG_ERROR(
"failed to write image file %s: i/o error.",
file_path);
return false;
}
catch (const Exception& e)
{
RENDERER_LOG_ERROR(
"failed to write image file %s: %s.",
file_path,
e.what());
return false;
}
stopwatch.measure();
RENDERER_LOG_INFO(
"wrote image file %s in %s.",
file_path,
pretty_time(stopwatch.get_seconds()).c_str());
return true;
}
示例3: render
// Render the project.
MasterRenderer::RenderingResult render()
{
// RenderingResult is initialized to Failed.
RenderingResult result;
// Perform basic integrity checks on the scene.
if (!check_scene())
return result;
// Initialize thread-local variables.
Spectrum::set_mode(get_spectrum_mode(m_params));
// Reset the frame's render info.
m_project.get_frame()->render_info().clear();
try
{
// Render.
m_stopwatch.start();
result.m_status = do_render();
m_stopwatch.measure();
result.m_render_time = m_stopwatch.get_seconds();
// Insert render time into the frame's render info.
// Note that the frame entity may have replaced during rendering.
ParamArray& render_info = m_project.get_frame()->render_info();
render_info.insert("render_time", result.m_render_time);
// Don't proceed further if rendering failed.
if (result.m_status != RenderingResult::Succeeded)
return result;
// Post-process.
m_stopwatch.start();
postprocess(result);
m_stopwatch.measure();
result.m_post_processing_time = m_stopwatch.get_seconds();
render_info.insert("post_processing_time", result.m_post_processing_time);
}
catch (const bad_alloc&)
{
m_renderer_controller->on_rendering_abort();
RENDERER_LOG_ERROR("rendering failed (ran out of memory).");
result.m_status = RenderingResult::Failed;
}
#ifdef NDEBUG
catch (const exception& e)
{
m_renderer_controller->on_rendering_abort();
RENDERER_LOG_ERROR("rendering failed (%s).", e.what());
result.m_status = RenderingResult::Failed;
}
catch (...)
{
m_renderer_controller->on_rendering_abort();
RENDERER_LOG_ERROR("rendering failed (unknown exception).");
result.m_status = RenderingResult::Failed;
}
#endif
return result;
}