diff options
author | Janne Blomqvist <jb@gcc.gnu.org> | 2012-05-27 10:09:15 +0300 |
---|---|---|
committer | Janne Blomqvist <jb@gcc.gnu.org> | 2012-05-27 10:09:15 +0300 |
commit | 1ca8bef0218b120d504b18a983b6da1f37f3acbe (patch) | |
tree | 4ba076dcff35f273033f62f07fd1e6239ab3bef4 /libgfortran/intrinsics | |
parent | f51a04db53984de477ab8ac318f7c731aebfd513 (diff) | |
download | gcc-1ca8bef0218b120d504b18a983b6da1f37f3acbe.zip gcc-1ca8bef0218b120d504b18a983b6da1f37f3acbe.tar.gz gcc-1ca8bef0218b120d504b18a983b6da1f37f3acbe.tar.bz2 |
Minor timing cleanups.
2012-05-27 Janne Blomqvist <jb@gcc.gnu.org>
* intrinsics/time_1.h (gf_cputime): Don't reevaluate HZ expression
for times fallback, clarify operation ordering for times and clock
fallbacks.
(gf_gettime): Fix comment typo.
From-SVN: r187922
Diffstat (limited to 'libgfortran/intrinsics')
-rw-r--r-- | libgfortran/intrinsics/time_1.h | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/libgfortran/intrinsics/time_1.h b/libgfortran/intrinsics/time_1.h index 94f2f3d..98a20d2 100644 --- a/libgfortran/intrinsics/time_1.h +++ b/libgfortran/intrinsics/time_1.h @@ -158,10 +158,11 @@ gf_cputime (long *user_sec, long *user_usec, long *system_sec, long *system_usec struct tms buf; clock_t err; err = times (&buf); - *user_sec = buf.tms_utime / HZ; - *user_usec = buf.tms_utime % HZ * (1000000. / HZ); - *system_sec = buf.tms_stime / HZ; - *system_usec = buf.tms_stime % HZ * (1000000. / HZ); + long hz = HZ; + *user_sec = buf.tms_utime / hz; + *user_usec = (buf.tms_utime % hz) * (1000000. / hz); + *system_sec = buf.tms_stime / hz; + *system_usec = (buf.tms_stime % hz) * (1000000. / hz); if ((err == (clock_t) -1) && errno != 0) return -1; return 0; @@ -184,7 +185,7 @@ gf_cputime (long *user_sec, long *user_usec, long *system_sec, long *system_usec #else clock_t c = clock (); *user_sec = c / CLOCKS_PER_SEC; - *user_usec = c % CLOCKS_PER_SEC * (1000000. / CLOCKS_PER_SEC); + *user_usec = (c % CLOCKS_PER_SEC) * (1000000. / CLOCKS_PER_SEC); *system_sec = *system_usec = 0; if (c == (clock_t) -1) return -1; @@ -204,7 +205,7 @@ gf_cputime (long *user_sec, long *user_usec, long *system_sec, long *system_usec usecs - OUTPUT, microseconds The OUTPUT arguments shall represent the number of seconds and - nanoseconds since the Epoch. + microseconds since the Epoch. Return value: 0 for success, -1 for error. In case of error, errno is set. |