RE: [boost] Re: high_resolution_timer \ timer feature requestsforBoost.Timer

The code I am using was originally developed by Christopher Diggins. His code allows for use of boost.timer or the high_resolution_timer. I am currently using the high_resolution timer. THANK YOU for the suggestion of using the microsec_time_clock.hpp. I did not know that existed, do you know how does this compare to the high_resolution timer? I need to stick to a base release version of boost for production reasons, do you think this other timer will work inside 1.32? Thank you very much for your thoughts, I would not have noticed the microsec if you had not pointed it out to me.
-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Caleb Epstein Sent: Friday, March 04, 2005 8:32 PM To: boost@lists.boost.org Subject: Re: [boost] Re: high_resolution_timer \ timer feature requestsforBoost.Timer
On Fri, 4 Mar 2005 10:42:16 -0700, Brian Braatz <brianb@rmtg.com> wrote:
But the Profile LOG (like a trace of what happened) looks like this DEPTH NAME TIME 0 FuncA 2 Seconds 1 FuncB 1 Second
Does that answer your question, or am I missing something?
Just a subtle point, but the boost::timer class returns CPU time used not elapsed wall-clock time and would return results of ~0.0 for a function that just sleep'd for a second or two.
If what you're looking for is a high-resolution clock, try <boost/date_time/microsec_time_clock.hpp> (at least in the latest CVS). If you want performance or profiling information, use boost::timer.
-- Caleb Epstein caleb dot epstein at gmail dot com _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

On Fri, 4 Mar 2005 23:41:10 -0700, Brian Braatz wrote
The code I am using was originally developed by Christopher Diggins. His code allows for use of boost.timer or the high_resolution_timer.
I am currently using the high_resolution timer.
THANK YOU for the suggestion of using the microsec_time_clock.hpp. I did not know that existed, do you know how does this compare to the high_resolution timer?
Sorry to be so far behind on this thread -- I'll just add a couple thoughts here. The microsecond timer is used to construct a posix_time::ptime instance which represents time to microsecond/nano second resolution. The usage looks like this: ptime t1 = microsec_clock::local_time(); //time in tz of computer in 1.32 ptime t2 = microsec_clock::universal_time(); //CVS only, time in UTC http://www.boost.org/doc/html/date_time/posix_time.html#ptime_from_clock In date-time the idea is that clocks can be developed independent of the time representation -- so if there is a platform specific or hardware driven clock it can integrate with the library simply by writing an adaptor function to constuct the time representation. Using microsecond_clock won't necessarily solve all your timing problems as it uses FILETIME on Windows and gettimeofday on Posix platforms.
I need to stick to a base release version of boost for production reasons, do you think this other timer will work inside 1.32?
Thank you very much for your thoughts, I would not have noticed the microsec if you had not pointed it out to me.
It's been on my todo list for awhile to replace the current boost.timer with one based on the concepts in date-time. It's just been behind a couple major projects related to I/O and local time representation. I've added a little example of how the current timer could be trivially rewritten using the date_time classes including the microsecond clock. If you need to prime the start time you could just create another constructor that takes a start time. //just replacing the current timer interfaces with date-time //classes like time_duration and posix_time class timer { public: timer() : start_time_(boost::posix_time::microsec_clock::local_time()) {} void restart() { start_time_ = microsec_clock::local_time(); } time_duration elapsed() const { return boost::posix_time::microsec_clock::local_time() - start_time_;} private: boost::posix_time::ptime start_time_; }; // timer The prior discussions of this issue and this example can be found at: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?GDTL/Timer Jeff
participants (2)
-
Brian Braatz
-
Jeff Garland