# HG changeset patch # User kevinw # Date 1583758493 0 # Node ID f3ceb2e8bd217eba4967fd6ee6c17443257b1dc0 # Parent fb74ae5912096e3a63ff144d7ec497dfb04eae7a 8240295: hs_err elapsed time in seconds is not accurate enough Reviewed-by: dholmes, sspitsyn diff -r fb74ae591209 -r f3ceb2e8bd21 src/share/vm/runtime/os.cpp --- a/src/share/vm/runtime/os.cpp Mon Jun 29 21:30:26 2020 +0100 +++ b/src/share/vm/runtime/os.cpp Mon Mar 09 12:54:53 2020 +0000 @@ -868,10 +868,9 @@ } double t = os::elapsedTime(); - // NOTE: It tends to crash after a SEGV if we want to printf("%f",...) in - // Linux. Must be a bug in glibc ? Workaround is to round "t" to int - // before printf. We lost some precision, but who cares? + // NOTE: a crash using printf("%f",...) on Linux was historically noted here. int eltime = (int)t; // elapsed time in seconds + int eltimeFraction = (int) ((t - eltime) * 1000000); // print elapsed time in a human-readable format: int eldays = eltime / secs_per_day; @@ -881,7 +880,7 @@ int elmins = (eltime - day_secs - hour_secs) / secs_per_min; int minute_secs = elmins * secs_per_min; int elsecs = (eltime - day_secs - hour_secs - minute_secs); - st->print_cr("elapsed time: %d seconds (%dd %dh %dm %ds)", eltime, eldays, elhours, elmins, elsecs); + st->print_cr(" elapsed time: %d.%06d seconds (%dd %dh %dm %ds)", eltime, eltimeFraction, eldays, elhours, elmins, elsecs); } // moved from debug.cpp (used to be find()) but still called from there