MCPcopy Create free account
hub / github.com/RenderKit/embree / getFormattedDuration

Function getFormattedDuration

tutorials/external/catch.hpp:13043–13059  ·  view source on GitHub ↗

Because formatting using c++ streams is stateful, drop down to C is required Alternatively we could use stringstream, but its performance is... not good.

Source from the content-addressed store, hash-verified

13041 // Because formatting using c++ streams is stateful, drop down to C is required
13042 // Alternatively we could use stringstream, but its performance is... not good.
13043 std::string getFormattedDuration( double duration ) {
13044 // Max exponent + 1 is required to represent the whole part
13045 // + 1 for decimal point
13046 // + 3 for the 3 decimal places
13047 // + 1 for null terminator
13048 const std::size_t maxDoubleSize = DBL_MAX_10_EXP + 1 + 1 + 3 + 1;
13049 char buffer[maxDoubleSize];
13050
13051 // Save previous errno, to prevent sprintf from overwriting it
13052 ErrnoGuard guard;
13053#ifdef _MSC_VER
13054 sprintf_s(buffer, "%.3f", duration);
13055#else
13056 std::sprintf(buffer, "%.3f", duration);
13057#endif
13058 return std::string(buffer);
13059 }
13060
13061 std::string serializeFilters( std::vector<std::string> const& container ) {
13062 ReusableStringStream oss;

Callers 1

sectionEndedMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected