From 1a2e49aadf8d24b022998d302db5491d375a9d4b Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Mon, 7 Mar 2016 19:20:39 +0000 Subject: [PATCH] Change the timestamp to [ssssss.s] to reduce the length of the stdout lines. --- configure.ac | 2 +- src/clocks.c | 26 +++++--------------------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/configure.ac b/configure.ac index 719b5e6897..6abf5a35bb 100644 --- a/configure.ac +++ b/configure.ac @@ -329,7 +329,7 @@ is defined in <sys/time.h>])],, [#if HAVE_SYS_TIME_H #include <sys/time.h> #endif]) -AC_CHECK_FUNCS([gethrtime read_real_time time_base_to_time clock_gettime mach_absolute_time strftime gettimeofday localtime]) +AC_CHECK_FUNCS([gethrtime read_real_time time_base_to_time clock_gettime mach_absolute_time]) AC_MSG_CHECKING([for _rtc intrinsic]) rtc_ok=yes AC_LINK_IFELSE([AC_LANG_PROGRAM( diff --git a/src/clocks.c b/src/clocks.c index ce220855d9..843970edf8 100644 --- a/src/clocks.c +++ b/src/clocks.c @@ -227,34 +227,18 @@ double clocks_from_ticks(ticks tics) { const char *clocks_getunit() { return clocks_units[clocks_units_index]; } /** - * @brief returns the time of day to 1/10th second accuracy. + * @brief returns the time since the start of the execution in seconds * - * The date is return in the format [hh:mm:ss.s] + * The time is return in the format [ssssss.s] * - * @result the current time of day. + * @result the time since the start of the execution */ const char *clocks_get_timeofday() { static char buffer[40]; -#if defined(HAVE_CLOCK_GETTIME) && defined(HAVE_LOCALTIME) && \ - defined(HAVE_STRFTIME) - struct timespec time; - struct tm *local_time; - char fmttime[40]; + sprintf(buffer, "[%08.1f]", + clocks_diff_ticks(getticks(), clocks_start) / 1000.0); - clock_gettime(CLOCK_REALTIME, &time); - local_time = localtime(&time.tv_sec); - - /* Make it a string */ - strftime(fmttime, 40, "%T", local_time); - - /* 1/10 seconds. */ - int tseconds = time.tv_nsec / 100000000; - sprintf(buffer, "[%s.%01d]", fmttime, tseconds); - -#else - sprintf(buffer, "[%08.1f]", clocks_diff_ticks(getticks(),clocks_start)/100.0); -#endif return buffer; } -- GitLab