< prev index next >

src/share/vm/runtime/os.cpp

Print this page




 830       }
 831     }
 832   }
 833 }
 834 
 835 void os::print_cpu_info(outputStream* st) {
 836   // cpu
 837   st->print("CPU:");
 838   st->print("total %d", os::processor_count());
 839   // It's not safe to query number of active processors after crash
 840   // st->print("(active %d)", os::active_processor_count()); but we can
 841   // print the initial number of active processors.
 842   // We access the raw value here because the assert in the accessor will
 843   // fail if the crash occurs before initialization of this value.
 844   st->print(" (initial active %d)", _initial_active_processor_count);
 845   st->print(" %s", VM_Version::cpu_features());
 846   st->cr();
 847   pd_print_cpu_info(st);
 848 }
 849 
 850 void os::print_date_and_time(outputStream *st) {
 851   const int secs_per_day  = 86400;
 852   const int secs_per_hour = 3600;
 853   const int secs_per_min  = 60;
 854 
 855   time_t tloc;
 856   (void)time(&tloc);
 857   st->print("time: %s", ctime(&tloc));  // ctime adds newline.






 858 
 859   double t = os::elapsedTime();
 860   // NOTE: It tends to crash after a SEGV if we want to printf("%f",...) in
 861   //       Linux. Must be a bug in glibc ? Workaround is to round "t" to int
 862   //       before printf. We lost some precision, but who cares?
 863   int eltime = (int)t;  // elapsed time in seconds
 864 
 865   // print elapsed time in a human-readable format:
 866   int eldays = eltime / secs_per_day;
 867   int day_secs = eldays * secs_per_day;
 868   int elhours = (eltime - day_secs) / secs_per_hour;
 869   int hour_secs = elhours * secs_per_hour;
 870   int elmins = (eltime - day_secs - hour_secs) / secs_per_min;
 871   int minute_secs = elmins * secs_per_min;
 872   int elsecs = (eltime - day_secs - hour_secs - minute_secs);
 873   st->print_cr("elapsed time: %d seconds (%dd %dh %dm %ds)", eltime, eldays, elhours, elmins, elsecs);
 874 }
 875 
 876 // moved from debug.cpp (used to be find()) but still called from there
 877 // The verbose parameter is only set by the debug code in one case




 830       }
 831     }
 832   }
 833 }
 834 
 835 void os::print_cpu_info(outputStream* st) {
 836   // cpu
 837   st->print("CPU:");
 838   st->print("total %d", os::processor_count());
 839   // It's not safe to query number of active processors after crash
 840   // st->print("(active %d)", os::active_processor_count()); but we can
 841   // print the initial number of active processors.
 842   // We access the raw value here because the assert in the accessor will
 843   // fail if the crash occurs before initialization of this value.
 844   st->print(" (initial active %d)", _initial_active_processor_count);
 845   st->print(" %s", VM_Version::cpu_features());
 846   st->cr();
 847   pd_print_cpu_info(st);
 848 }
 849 
 850 void os::print_date_and_time(outputStream *st, char* buf, size_t buflen) {
 851   const int secs_per_day  = 86400;
 852   const int secs_per_hour = 3600;
 853   const int secs_per_min  = 60;
 854 
 855   time_t tloc;
 856   (void)time(&tloc);
 857   st->print("time: %s", ctime(&tloc));  // ctime adds newline.
 858 
 859   struct tm tz;
 860   if (localtime_pd(&tloc, &tz) != NULL) {
 861     ::strftime(buf, buflen, "%Z", &tz);
 862     st->print_cr("timezone: %s", buf);
 863   }
 864 
 865   double t = os::elapsedTime();
 866   // NOTE: It tends to crash after a SEGV if we want to printf("%f",...) in
 867   //       Linux. Must be a bug in glibc ? Workaround is to round "t" to int
 868   //       before printf. We lost some precision, but who cares?
 869   int eltime = (int)t;  // elapsed time in seconds
 870 
 871   // print elapsed time in a human-readable format:
 872   int eldays = eltime / secs_per_day;
 873   int day_secs = eldays * secs_per_day;
 874   int elhours = (eltime - day_secs) / secs_per_hour;
 875   int hour_secs = elhours * secs_per_hour;
 876   int elmins = (eltime - day_secs - hour_secs) / secs_per_min;
 877   int minute_secs = elmins * secs_per_min;
 878   int elsecs = (eltime - day_secs - hour_secs - minute_secs);
 879   st->print_cr("elapsed time: %d seconds (%dd %dh %dm %ds)", eltime, eldays, elhours, elmins, elsecs);
 880 }
 881 
 882 // moved from debug.cpp (used to be find()) but still called from there
 883 // The verbose parameter is only set by the debug code in one case


< prev index next >