Boost logo

Boost :

From: SourceForge.net (noreply_at_[hidden])
Date: 2003-08-14 10:22:13


Bugs item #788762, was opened at 2003-08-14 10:22
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=788762&group_id=7586

Category: timer
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Shannon Glenn Barber (magmaikh)
Assigned to: Beman Dawes (beman_dawes)
Summary: clock is not portable

Initial Comment:
On Win32 clock reports total elapsed time.
On GNU/Linux clock reports consumed processor time by
that process, and only reports time on the primary
thread. Other threads always return 0, and time spent
usleep'ing is not counted.

The wording of the C/C++ standard is not without room
for interpretation, and may even be interpreted to mean
do whatever you can for clock.

On Linux, and very possibly other *nix's, the function
gettimeofday (in sys/time.h) should probably be used.

code dump of my linux timer follows:

template<typename T>
struct HPTimer
        {
        i64 Now_us()
                {
                timeval now;
                MKH_THROWONFAILURE(gettimeofday
(&tvnow, 0));
                return i64(now.tv_sec) * 1000000 +
now.tv_usec;
                }
        T Snap()
                {
                timeval snap;
                //timezone zn;
                MKH_THROWONFAILURE(gettimeofday
(&snap, 0));
                i64 now = i64(snap.tv_sec) *
1000000 + snap.tv_usec;
                i64 then = i64(prev_snap.tv_sec) *
1000000 + prev_snap.tv_usec;
                prev_snap = snap;
                return T(now - then) / 1000000;
                }
        protected:
                timeval prev_snap;
        };

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=107586&aid=788762&group_id=7586

-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
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