Boost logo

Boost Users :

Subject: Re: [Boost-users] A problem on using boost timer (different time intervals were showed). Can any one with kindness help me?
From: Chris Uzdavinis (cuzdav_at_[hidden])
Date: 2009-09-24 16:20:46


On Thu, Sep 24, 2009 at 4:08 PM, Dominique Devienne > Windows does
support a high resolution timer, but I could never find a good impl
> to re-use, and it's not portable of course. I wish Boost provided such
> a high res timer in a portable manner :) --DD

Not sure if boost/posix_time is portable enough for you, but:

#include "boost/date_time/posix_time/posix_time.hpp"

void example() {
  boost::posix_time::ptime begin;
  boost::posix_time::ptime end;

  begin = boost::posix_time::microsec_clock::universal_time();
  do_something();
  end = boost::posix_time::microsec_clock::universal_time();

  std::cout << boost::posix_time::to_simple_string(end - begin);
}

Chris


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net