本文整理汇总了C++中Stopwatch::measure方法的典型用法代码示例。如果您正苦于以下问题:C++ Stopwatch::measure方法的具体用法?C++ Stopwatch::measure怎么用?C++ Stopwatch::measure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stopwatch
的用法示例。
在下文中一共展示了Stopwatch::measure方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: message_context
CurveTree::CurveTree(const Arguments& arguments)
: TreeType(AlignedAllocator<void>(System::get_l1_data_cache_line_size()))
, m_arguments(arguments)
{
// Retrieve construction parameters.
const MessageContext message_context(
format("while building curve tree for assembly \"{0}\"", m_arguments.m_assembly.get_path()));
const ParamArray& params = m_arguments.m_assembly.get_parameters().child("acceleration_structure");
const string algorithm = params.get_optional<string>("algorithm", "bvh", make_vector("bvh", "sbvh"), message_context);
const double time = params.get_optional<double>("time", 0.5);
// Start stopwatch.
Stopwatch<DefaultWallclockTimer> stopwatch;
stopwatch.start();
// Build the tree.
Statistics statistics;
if (algorithm == "bvh")
build_bvh(params, time, statistics);
else throw ExceptionNotImplemented();
// Print curve tree statistics.
statistics.insert_size("nodes alignment", alignment(&m_nodes[0]));
statistics.insert_time("total time", stopwatch.measure().get_seconds());
RENDERER_LOG_DEBUG("%s",
StatisticsVector::make(
"curve tree #" + to_string(m_arguments.m_curve_tree_uid) + " statistics",
statistics).to_string().c_str());
}
示例4: 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;
}
示例5: if
//.........这里部分代码省略.........
rtcSetGeometryTimeStepCount(
geometry_handle,
geometry_data->m_motion_steps_count);
geometry_data->m_geometry_handle = geometry_handle;
const unsigned int vertices_count = geometry_data->m_vertices_count;
const unsigned int vertices_stride = geometry_data->m_vertices_stride;
for (unsigned int m = 0; m < geometry_data->m_motion_steps_count; ++m)
{
// Byte offset for the current motion segment.
const unsigned int vertices_offset = m * vertices_count * vertices_stride;
// Set vertices.
rtcSetSharedGeometryBuffer(
geometry_handle, // geometry
RTC_BUFFER_TYPE_VERTEX, // buffer type
m, // slot
RTC_FORMAT_FLOAT3, // format
geometry_data->m_vertices, // buffer
vertices_offset, // byte offset
vertices_stride, // byte stride
vertices_count); // item count
}
// Set vertex indices.
rtcSetSharedGeometryBuffer(
geometry_handle, // geometry
RTC_BUFFER_TYPE_INDEX, // buffer type
0, // slot
RTC_FORMAT_UINT3, // format
geometry_data->m_primitives, // buffer
0, // byte offset
geometry_data->m_primitives_stride, // byte stride
geometry_data->m_primitives_count); // item count
rtcSetGeometryMask(
geometry_handle,
geometry_data->m_vis_flags);
rtcCommitGeometry(geometry_handle);
}
else if (strcmp(object_model, CurveObjectFactory().get_model()) == 0)
{
geometry_data->m_geometry_type = RTC_GEOMETRY_TYPE_FLAT_BEZIER_CURVE;
// Retrieve curve data.
collect_curve_data(*object_instance, *geometry_data);
geometry_handle = rtcNewGeometry(
m_device,
RTC_GEOMETRY_TYPE_FLAT_BEZIER_CURVE);
rtcSetGeometryBuildQuality(
geometry_handle,
RTCBuildQuality::RTC_BUILD_QUALITY_HIGH);
// Set vertices. (x_pos, y_pos, z_pos, radii)
rtcSetSharedGeometryBuffer(
geometry_handle, // geometry
RTC_BUFFER_TYPE_INDEX, // buffer type
0, // slot
RTC_FORMAT_FLOAT4, // format
geometry_data->m_vertices, // buffer
0, // byte offset
geometry_data->m_vertices_stride, // byte stride
geometry_data->m_vertices_count); // item count
// Set vertex indices.
rtcSetSharedGeometryBuffer(
geometry_handle, // geometry
RTC_BUFFER_TYPE_INDEX, // buffer type
0, // slot
RTC_FORMAT_UINT4, // format
geometry_data->m_primitives, // buffer
0, // byte offset
geometry_data->m_primitives_stride, // byte stride
geometry_data->m_primitives_count); // item count
}
else
{
// Unsupported object type.
continue;
}
rtcAttachGeometryByID(m_scene, geometry_handle, static_cast<unsigned int>(instance_idx));
m_geometry_container.push_back(std::move(geometry_data));
}
rtcCommitScene(m_scene);
statistics.insert_time("total build time", stopwatch.measure().get_seconds());
RENDERER_LOG_DEBUG("%s",
StatisticsVector::make(
"Embree scene #" + to_string(arguments.m_assembly.get_uid()) + " statistics",
statistics).to_string().c_str());
}