Skip to content

Instantly share code, notes, and snippets.

@motonacciu
Last active December 17, 2015 10:48
Show Gist options
  • Select an option

  • Save motonacciu/5597160 to your computer and use it in GitHub Desktop.

Select an option

Save motonacciu/5597160 to your computer and use it in GitHub Desktop.
std::tuple<int,int,std::vector<uint8_t>> t(10, 20, {0,1,2,3,4,5,6,7,8,9});
TEST(Performance, Water) {
auto start = std::chrono::high_resolution_clock::now();
for (size_t i=0; i<500000; ++i) {
StreamType res;
serialize(t,res);
}
auto tot_time = std::chrono::duration_cast<std::chrono::microseconds>(
std::chrono::system_clock::now()-start).count();
std::cout << "time: " << tot_time << std::endl;
}
/* boost serializer */
template <class T>
inline std::string to_bytes(const T &v) {
std::ostringstream ss;
boost::archive::text_oarchive oa(ss);
oa << v;
return ss.str();
}
TEST(Performance, Boost) {
auto start = std::chrono::high_resolution_clock::now();
StreamType res;
for (size_t i=0; i<500000; ++i) { to_bytes(t1); }
auto tot_time = std::chrono::duration_cast<std::chrono::microseconds>(
std::chrono::system_clock::now()-start).count();
std::cout << "time: " << tot_time << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment