8240295: hs_err elapsed time in seconds is not accurate enough

Mon, 09 Mar 2020 12:54:53 +0000

author
kevinw
date
Mon, 09 Mar 2020 12:54:53 +0000
changeset 9950
f3ceb2e8bd21
parent 9949
fb74ae591209
child 9951
2f07f8d27acf

8240295: hs_err elapsed time in seconds is not accurate enough
Reviewed-by: dholmes, sspitsyn

src/share/vm/runtime/os.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/runtime/os.cpp	Mon Jun 29 21:30:26 2020 +0100
     1.2 +++ b/src/share/vm/runtime/os.cpp	Mon Mar 09 12:54:53 2020 +0000
     1.3 @@ -868,10 +868,9 @@
     1.4    }
     1.5  
     1.6    double t = os::elapsedTime();
     1.7 -  // NOTE: It tends to crash after a SEGV if we want to printf("%f",...) in
     1.8 -  //       Linux. Must be a bug in glibc ? Workaround is to round "t" to int
     1.9 -  //       before printf. We lost some precision, but who cares?
    1.10 +  // NOTE: a crash using printf("%f",...) on Linux was historically noted here.
    1.11    int eltime = (int)t;  // elapsed time in seconds
    1.12 +  int eltimeFraction = (int) ((t - eltime) * 1000000);
    1.13  
    1.14    // print elapsed time in a human-readable format:
    1.15    int eldays = eltime / secs_per_day;
    1.16 @@ -881,7 +880,7 @@
    1.17    int elmins = (eltime - day_secs - hour_secs) / secs_per_min;
    1.18    int minute_secs = elmins * secs_per_min;
    1.19    int elsecs = (eltime - day_secs - hour_secs - minute_secs);
    1.20 -  st->print_cr("elapsed time: %d seconds (%dd %dh %dm %ds)", eltime, eldays, elhours, elmins, elsecs);
    1.21 +  st->print_cr(" elapsed time: %d.%06d seconds (%dd %dh %dm %ds)", eltime, eltimeFraction, eldays, elhours, elmins, elsecs);
    1.22  }
    1.23  
    1.24  // moved from debug.cpp (used to be find()) but still called from there

mercurial