c++ - How to calculate the time difference in microseconds between two timestamps using the Boost library -
update: code compiles properly
i calculate time difference between 2 timestamps. resolution of import must in microseconds/milliseconds.
i tried next result not meaningful:
boost::posix_time::ptime before = (&input[0])->timestamp; boost::posix_time::ptime = boost::posix_time::microsec_clock::local_time(); boost::posix_time::time_period tp (before, now); std::string str (boost::posix_time::to_simple_string (tp)); cout << str.c_str() << endl; the result following:
[2014-jun-20 12:26:07.711182/2014-jun-20 12:26:07.711596] how can next instead?
76 μs
you can use
std::cout << (now - before).total_microseconds() << " µs\n"; std::cout << (now - before).total_milliseconds() << " ms\n"; this want (printing e.g. 76 µs or 314 ms)
c++ boost time
No comments:
Post a Comment