This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch, libfortran] Minor timing cleanups
- From: Janne Blomqvist <blomqvist dot janne at gmail dot com>
- To: Fortran List <fortran at gcc dot gnu dot org>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 27 May 2012 10:10:24 +0300
- Subject: [Patch, libfortran] Minor timing cleanups
Hi,
I committed the patch below as obvious.
Index: intrinsics/time_1.h
===================================================================
--- intrinsics/time_1.h (revision 187921)
+++ intrinsics/time_1.h (working copy)
@@ -158,10 +158,11 @@ gf_cputime (long *user_sec, long *user_u
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_u
#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_u
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.
Index: ChangeLog
===================================================================
--- ChangeLog (revision 187921)
+++ ChangeLog (working copy)
@@ -1,3 +1,10 @@
+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.
+
2012-05-24 Janne Blomqvist <jb@gcc.gnu.org>
PR fortran/53456
--
Janne Blomqvist