|
Boost : |
From: SourceForge.net (noreply_at_[hidden])
Date: 2006-07-11 07:41:56
Bugs item #1520489, was opened at 2006-07-11 15:41
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=107586&aid=1520489&group_id=7586
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: timer
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Sukhonosenko Kirill (skv)
Assigned to: Beman Dawes (beman_dawes)
Summary: significantly different timer class behaviour on Win and Lin
Initial Comment:
clock() function used in implementation of
boost::timer behaves differently on Windows (MS XP
Pro, MSVC 7.1) and Linux (FC3, gcc 3.4.2).
Windows: clock measures elapsed time (wall clock).
And this comply with boost::timer interface
description.
Example:
boost::timer t;
double sec = 1;
::Sleep(sec*1000);
double d = t.elapsed();
assert(abs(d-sec) < 0.1);
Linux: clock() function returnes process CPU time.
The above code will fail.
This difference makes boost::timer a bad candidate
for cross-platform development. I can propose
alternative implementation with simalar right
behaviour.
------------------------------------------
#ifndef
_Timer_h_dlfkgh9384ytdflg9045uhy0823475mgd385uyn0v68uy
c0n4c5
#define
_Timer_h_dlfkgh9384ytdflg9045uhy0823475mgd385uyn0v68uy
c0n4c5
#include <time.h>
namespace Timer
{
/*
Measures intervals of wall clock time, but
not process CPU time. Resolution & accuracy depends
on time function abilities.
*/
class timer
{
public:
// setup reference time point
timer()
{
restart();
}
// reset reference time point
void restart()
{
::time(&m_ref_time);
}
// report difference between current
time and reference point
double elapsed() const
{
time_t curr_time;
::time(&curr_time);
double diff = difftime
(curr_time, m_ref_time);
return diff;
}
// forbidden
private:
timer(const timer &);
timer & operator=(const timer &);
private:
time_t m_ref_time;
};
} // namespace Timer
#endif //_Timer_h_dlfkgh9384ytdflg9045uhy0823475mgd385
uyn0v68uyc0n4c5
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=107586&aid=1520489&group_id=7586
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Boost-bugs mailing list
Boost-bugs_at_[hidden]
https://lists.sourceforge.net/lists/listinfo/boost-bugs
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk