mirror of
https://github.com/USCiLab/cereal.git
synced 2025-10-18 01:45:52 +02:00
Fixing performance timing output to match that from develop branch
Adding documentation to MSVC only JSON changes for saving
This commit is contained in:
@@ -106,14 +106,25 @@ namespace cereal
|
|||||||
void saveValue(double d) { itsWriter.Double(d); }
|
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(std::string const & s) { itsWriter.String(s.c_str(), static_cast<rapidjson::SizeType>( s.size() )); }
|
||||||
void saveValue(char const * s) { itsWriter.String(s); }
|
void saveValue(char const * s) { itsWriter.String(s); }
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#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
|
template <class T> inline
|
||||||
typename std::enable_if<sizeof(T) == sizeof(std::uint32_t), void>::type
|
typename std::enable_if<sizeof(T) == sizeof(std::uint32_t), void>::type
|
||||||
saveLong(T lu){ saveValue( static_cast<std::uint32_t>( lu ) ); }
|
saveLong(T lu){ saveValue( static_cast<std::uint32_t>( lu ) ); }
|
||||||
|
|
||||||
|
//! non 32 bit long saving
|
||||||
template <class T> inline
|
template <class T> inline
|
||||||
typename std::enable_if<sizeof(T) != sizeof(std::uint32_t), void>::type
|
typename std::enable_if<sizeof(T) != sizeof(std::uint32_t), void>::type
|
||||||
saveLong(T lu){ saveValue( static_cast<std::uint64_t>( lu ) ); }
|
saveLong(T lu){ saveValue( static_cast<std::uint64_t>( lu ) ); }
|
||||||
|
|
||||||
|
//! MSVC only long overload
|
||||||
void saveValue( unsigned long lu ){ saveLong( lu ); };
|
void saveValue( unsigned long lu ){ saveLong( lu ); };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -200,18 +200,18 @@ void test( std::string const & name,
|
|||||||
|
|
||||||
std::cout << " Boost results:" << std::endl;
|
std::cout << " Boost results:" << std::endl;
|
||||||
std::cout << boost::format("\tsave | time: %06.4fms (%1.2f) size: %20.8fkb (%1.8f) total: %6.1fms")
|
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 << std::endl;
|
||||||
std::cout << boost::format("\tload | time: %06.4fms (%1.2f) total: %6.1fms")
|
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 << std::endl;
|
||||||
|
|
||||||
std::cout << " Cereal results:" << 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")
|
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 << std::endl;
|
||||||
std::cout << boost::format("\tload | time: %06.4fms (%1.2f) total: %6.1fms")
|
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;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user