src/os/bsd/vm/os_bsd.cpp

Print this page




 918 ////////////////////////////////////////////////////////////////////////////////
 919 // time support
 920 
 921 // Time since start-up in seconds to a fine granularity.
 922 // Used by VMSelfDestructTimer and the MemProfiler.
 923 double os::elapsedTime() {
 924 
 925   return (double)(os::elapsed_counter()) * 0.000001;
 926 }
 927 
 928 jlong os::elapsed_counter() {
 929   timeval time;
 930   int status = gettimeofday(&time, NULL);
 931   return jlong(time.tv_sec) * 1000 * 1000 + jlong(time.tv_usec) - initial_time_count;
 932 }
 933 
 934 jlong os::elapsed_frequency() {
 935   return (1000 * 1000);
 936 }
 937 
 938 // XXX: For now, code this as if BSD does not support vtime.
 939 bool os::supports_vtime() { return false; }
 940 bool os::enable_vtime()   { return false; }
 941 bool os::vtime_enabled()  { return false; }

 942 double os::elapsedVTime() {
 943   // better than nothing, but not much
 944   return elapsedTime();
 945 }
 946 
 947 jlong os::javaTimeMillis() {
 948   timeval time;
 949   int status = gettimeofday(&time, NULL);
 950   assert(status != -1, "bsd error");
 951   return jlong(time.tv_sec) * 1000  +  jlong(time.tv_usec / 1000);
 952 }
 953 
 954 #ifndef CLOCK_MONOTONIC
 955 #define CLOCK_MONOTONIC (1)
 956 #endif
 957 
 958 #ifdef __APPLE__
 959 void os::Bsd::clock_init() {
 960         // XXXDARWIN: Investigate replacement monotonic clock
 961 }




 918 ////////////////////////////////////////////////////////////////////////////////
 919 // time support
 920 
 921 // Time since start-up in seconds to a fine granularity.
 922 // Used by VMSelfDestructTimer and the MemProfiler.
 923 double os::elapsedTime() {
 924 
 925   return (double)(os::elapsed_counter()) * 0.000001;
 926 }
 927 
 928 jlong os::elapsed_counter() {
 929   timeval time;
 930   int status = gettimeofday(&time, NULL);
 931   return jlong(time.tv_sec) * 1000 * 1000 + jlong(time.tv_usec) - initial_time_count;
 932 }
 933 
 934 jlong os::elapsed_frequency() {
 935   return (1000 * 1000);
 936 }
 937 
 938 bool os::supports_vtime() { return true; }

 939 bool os::enable_vtime()   { return false; }
 940 bool os::vtime_enabled()  { return false; }
 941 
 942 double os::elapsedVTime() {
 943   // better than nothing, but not much
 944   return elapsedTime();
 945 }
 946 
 947 jlong os::javaTimeMillis() {
 948   timeval time;
 949   int status = gettimeofday(&time, NULL);
 950   assert(status != -1, "bsd error");
 951   return jlong(time.tv_sec) * 1000  +  jlong(time.tv_usec / 1000);
 952 }
 953 
 954 #ifndef CLOCK_MONOTONIC
 955 #define CLOCK_MONOTONIC (1)
 956 #endif
 957 
 958 #ifdef __APPLE__
 959 void os::Bsd::clock_init() {
 960         // XXXDARWIN: Investigate replacement monotonic clock
 961 }