incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Black <abl...@roguewave.com>
Subject Re: [PATCH] wall clock timing
Date Tue, 10 Oct 2006 22:36:43 GMT
Martin Sebor wrote:
> Andrew Black wrote:
[snip]
> but I'm not sure gettimeofday() is the best function for this.
> Wouldn't times() be better?
> http://www.opengroup.org/onlinepubs/009695399/functions/times.html
> 
> Btw., this also raises the question whether we could use times()
> instead of getrusage() as well? It would be more efficient than
> making two calls, one to getrusage() and another to gettimeofday(),
> and it might also be more efficient since getrusage() typically
> gathers/reports other data besides process times.
> 
> One last thing. While reading the POSIX spec I noticed that the
> time_t and clock_t types may be integer or floating point while
> our code seems to be making the assumption that they are the
> former. We should fix that.
> 
> Thanks
> Martin

Attached is a patch that attempts to simplify the logic flow by using 
times() rather than getrusage() and gettimeofday().  Given that we found 
Open Solaris implements times() in terms of getrusage() and 
gettimeofday(), any speed gains will likely be negligible, but the code 
should be cleaner.  I believe assumptions about the underlying data type 
for clock_t are removed, but I'm not certain.

--Andrew Black

Log:
	* cmdopt.h (TICKS_PER_SEC): Declare global constant
	* cmdopt.cpp (TICKS_PER_SEC): Define, value dependent on pre-processor 
declarations.
	* target.h (sys/time.h) [!_WIN32 && !_WIN64 && _XOPEN_UNIX]: Remove 
dependency.
	  (rw_timeval): Remove as unneeded.
	  (rw_time_t, rw_suseconds_t) [_XOPEN_UNIX]: Ditto.
	  (target_status): Use clock_t rather than rw_timeval.
	* exec.cpp (sys/times.h) [!_WIN32 && !_WIN64]: Include.
	  (sys/time.h) [!_WIN32 && !_WIN64 && _XOPEN_UNIX]: Remove dependency.
	  (calculate_usage) [!_WIN32 && !_WIN64]: Update documentation, alter 
signature, use times() rather than getrusage() to retrieve timing 
information.
	  (exec_file) [!_WIN32 && !_WIN64]: Move wall clock timing logic into 
calculate_usage, retrieve starting times prior to wait_for_child()
	  exec_file) [_WIN32 || _WIN64]: Simplify wall clock delta logic.
	* display.h (unistd.h) [!_WIN32 && !_WIN64]: Remove dependency.
	  (print_status_plain): Alter logic used to print times, reflecting 
change to target_status.

Mime
View raw message