Fixing performance timing output to match that from develop branch

Adding documentation to MSVC only JSON changes for saving
This commit is contained in:
Shane Grant
2013-07-22 09:49:56 -07:00
parent b48f57c23b
commit c2a47f51b5
2 changed files with 15 additions and 4 deletions

View File

@@ -106,14 +106,25 @@ namespace cereal
void saveValue(double d) { itsWriter.Double(d); }
void saveValue(std::string const & s) { itsWriter.String(s.c_str(), static_cast<rapidjson::SizeType>( s.size() )); }
void saveValue(char const * s) { itsWriter.String(s); }
#ifdef _MSC_VER
// Visual Studio has problems disambiguating the above for unsigned long, so we provide an explicit
// overload for long and serialize it as its size necessitates
//
// When loading we don't need to do this specialization since we catch the types with
// templates according to their size
//! 32 bit long saving
template <class T> inline
typename std::enable_if<sizeof(T) == sizeof(std::uint32_t), void>::type
saveLong(T lu){ saveValue( static_cast<std::uint32_t>( lu ) ); }
//! non 32 bit long saving
template <class T> inline
typename std::enable_if<sizeof(T) != sizeof(std::uint32_t), void>::type
saveLong(T lu){ saveValue( static_cast<std::uint64_t>( lu ) ); }
//! MSVC only long overload
void saveValue( unsigned long lu ){ saveLong( lu ); };
#endif

View File

@@ -200,18 +200,18 @@ void test( std::string const & name,
std::cout << " Boost results:" << std::endl;
std::cout << boost::format("\tsave | time: %06.4fms (%1.2f) size: %20.8fkb (%1.8f) total: %6.1fms")
% averageBoostSave % 1.0 % (boostSize / 1024.0) % 1.0 % static_cast<double>( totalBoostSave.count() );
% averageBoostSave % 1.0 % (boostSize / 1024.0) % 1.0 % static_cast<double>( std::chrono::duration_cast<std::chrono::milliseconds>(totalBoostSave).count() );
std::cout << std::endl;
std::cout << boost::format("\tload | time: %06.4fms (%1.2f) total: %6.1fms")
% averageBoostLoad % 1.0 % static_cast<double>( totalBoostLoad.count() );
% averageBoostLoad % 1.0 % static_cast<double>( std::chrono::duration_cast<std::chrono::milliseconds>(totalBoostLoad).count() );
std::cout << std::endl;
std::cout << " Cereal results:" << std::endl;
std::cout << boost::format("\tsave | time: %06.4fms (%1.2f) size: %20.8fkb (%1.8f) total: %6.1fms")
% averageCerealSave % cerealSaveP % (cerealSize / 1024.0) % cerealSizeP % static_cast<double>( totalCerealSave.count() );
% averageCerealSave % cerealSaveP % (cerealSize / 1024.0) % cerealSizeP % static_cast<double>( std::chrono::duration_cast<std::chrono::milliseconds>(totalCerealSave).count() );
std::cout << std::endl;
std::cout << boost::format("\tload | time: %06.4fms (%1.2f) total: %6.1fms")
% averageCerealLoad % cerealLoadP % static_cast<double>( totalCerealLoad.count() );
% averageCerealLoad % cerealLoadP % static_cast<double>( std::chrono::duration_cast<std::chrono::milliseconds>(totalCerealLoad).count() );
std::cout << std::endl;
}