Skip to content
Permalink
Browse files
8240295: hs_err elapsed time in seconds is not accurate enough
Backport-of: a11912c
  • Loading branch information
Larry-N authored and Yuri Nesterenko committed Mar 19, 2021
1 parent 6d32c41 commit e53c5601df18044de886e8ae17b84cedbe8b581a
Showing 1 changed file with 3 additions and 4 deletions.
@@ -999,10 +999,9 @@ void os::print_date_and_time(outputStream *st, char* buf, size_t buflen) {
}

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;
@@ -1012,7 +1011,7 @@ void os::print_date_and_time(outputStream *st, char* buf, size_t buflen) {
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);
}


1 comment on commit e53c560

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on e53c560 Mar 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.