Print time with 2 digits after the decimal

This commit is contained in:
Patrick Pelissier committed 2023-04-08 11:25:59 +02:00
1 parent b8a9073fc9
commit 6bed3ac697
1 file changed
+2 -3
+2 -3
View File
@@ -55,7 +55,7 @@
// Number of elements of a table // Number of elements of a table
#define numberof(x) (sizeof(x)/sizeof(x[0])) #define numberof(x) (sizeof(x)/sizeof(x[0]))
/* Get the current CPU time. */ /* Get the current CPU time in microsecond. */
#if defined(_WIN32) #if defined(_WIN32)
/* WINDOWS variant */ /* WINDOWS variant */
static inline unsigned long long static inline unsigned long long
@@ -119,9 +119,8 @@ test_function(const char *str, size_t n, void (*func)(size_t))
(*func)(n); (*func)(n);
end = cputime(); end = cputime();
result = (double)(end-start) / 1000.0; result = (double)(end-start) / 1000.0;
end = (end - start) / 1000U;
if (str != NULL) { if (str != NULL) {
printf ("%20.20s time %lu ms for n = %lu [r=%lu]\n", str, (unsigned long) end, (unsigned long) n, g_result); printf ("%20.20s time %.2f ms for n = %lu [r=%lu]\n", str, result, (unsigned long) n, g_result);
} }
return result; return result;
} }