src/share/vm/runtime/os.cpp

Print this page

        

@@ -935,11 +935,17 @@
 
   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?
-  st->print_cr("elapsed time: %d seconds", (int)t);
+  int eltime = (int)t;  // elapsed time in seconds
+  int eldays, elhours, elminutes, elseconds;  // for printing elapsed time in a humanly readable format
+  eldays = eltime / 86400;
+  elhours = (eltime - eldays * 86400) / 3600;
+  elminutes = (eltime - eldays * 86400 - elhours * 3600) / 60;
+  elseconds = (eltime - eldays * 86400 - elhours * 3600 - elminutes * 60);
+  st->print_cr("elapsed time: %d seconds (%dd %dh %dm %ds)", eltime, eldays, elhours, elminutes, elseconds);
 }
 
 // moved from debug.cpp (used to be find()) but still called from there
 // The verbose parameter is only set by the debug code in one case
 void os::print_location(outputStream* st, intptr_t x, bool verbose) {