Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.
/ jdk13u-dev Public archive

Commit e53c560

Browse files
Larry-NYuri Nesterenko
authored and
Yuri Nesterenko
committedMar 19, 2021
8240295: hs_err elapsed time in seconds is not accurate enough
Backport-of: a11912c
1 parent 6d32c41 commit e53c560

File tree

1 file changed

+3
-4
lines changed
  • src/hotspot/share/runtime

1 file changed

+3
-4
lines changed
 

‎src/hotspot/share/runtime/os.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -999,10 +999,9 @@ void os::print_date_and_time(outputStream *st, char* buf, size_t buflen) {
999999
}
10001000

10011001
double t = os::elapsedTime();
1002-
// NOTE: It tends to crash after a SEGV if we want to printf("%f",...) in
1003-
// Linux. Must be a bug in glibc ? Workaround is to round "t" to int
1004-
// before printf. We lost some precision, but who cares?
1002+
// NOTE: a crash using printf("%f",...) on Linux was historically noted here.
10051003
int eltime = (int)t; // elapsed time in seconds
1004+
int eltimeFraction = (int) ((t - eltime) * 1000000);
10061005

10071006
// print elapsed time in a human-readable format:
10081007
int eldays = eltime / secs_per_day;
@@ -1012,7 +1011,7 @@ void os::print_date_and_time(outputStream *st, char* buf, size_t buflen) {
10121011
int elmins = (eltime - day_secs - hour_secs) / secs_per_min;
10131012
int minute_secs = elmins * secs_per_min;
10141013
int elsecs = (eltime - day_secs - hour_secs - minute_secs);
1015-
st->print_cr(" elapsed time: %d seconds (%dd %dh %dm %ds)", eltime, eldays, elhours, elmins, elsecs);
1014+
st->print_cr(" elapsed time: %d.%06d seconds (%dd %dh %dm %ds)", eltime, eltimeFraction, eldays, elhours, elmins, elsecs);
10161015
}
10171016

10181017

0 commit comments

Comments
 (0)