< prev index next >

hotspot/src/os/aix/vm/os_aix.cpp

Print this page


   1 /*
   2  * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright 2012, 2014 SAP AG. All rights reserved.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   8  * published by the Free Software Foundation.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.


1098 bool os::vtime_enabled()  { return false; }
1099 
1100 double os::elapsedVTime() {
1101   struct rusage usage;
1102   int retval = getrusage(RUSAGE_THREAD, &usage);
1103   if (retval == 0) {
1104     return usage.ru_utime.tv_sec + usage.ru_stime.tv_sec + (usage.ru_utime.tv_usec + usage.ru_stime.tv_usec) / (1000.0 * 1000);
1105   } else {
1106     // better than nothing, but not much
1107     return elapsedTime();
1108   }
1109 }
1110 
1111 jlong os::javaTimeMillis() {
1112   timeval time;
1113   int status = gettimeofday(&time, NULL);
1114   assert(status != -1, "aix error at gettimeofday()");
1115   return jlong(time.tv_sec) * 1000 + jlong(time.tv_usec / 1000);
1116 }
1117 









1118 // We need to manually declare mread_real_time,
1119 // because IBM didn't provide a prototype in time.h.
1120 // (they probably only ever tested in C, not C++)
1121 extern "C"
1122 int mread_real_time(timebasestruct_t *t, size_t size_of_timebasestruct_t);
1123 
1124 jlong os::javaTimeNanos() {
1125   if (os::Aix::on_pase()) {
1126     Unimplemented();
1127     return 0;
1128   } else {
1129     // On AIX use the precision of processors real time clock
1130     // or time base registers.
1131     timebasestruct_t time;
1132     int rc;
1133 
1134     // If the CPU has a time register, it will be used and
1135     // we have to convert to real time first. After convertion we have following data:
1136     // time.tb_high [seconds since 00:00:00 UTC on 1.1.1970]
1137     // time.tb_low  [nanoseconds after the last full second above]


   1 /*
   2  * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright 2012, 2014 SAP AG. All rights reserved.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   8  * published by the Free Software Foundation.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.


1098 bool os::vtime_enabled()  { return false; }
1099 
1100 double os::elapsedVTime() {
1101   struct rusage usage;
1102   int retval = getrusage(RUSAGE_THREAD, &usage);
1103   if (retval == 0) {
1104     return usage.ru_utime.tv_sec + usage.ru_stime.tv_sec + (usage.ru_utime.tv_usec + usage.ru_stime.tv_usec) / (1000.0 * 1000);
1105   } else {
1106     // better than nothing, but not much
1107     return elapsedTime();
1108   }
1109 }
1110 
1111 jlong os::javaTimeMillis() {
1112   timeval time;
1113   int status = gettimeofday(&time, NULL);
1114   assert(status != -1, "aix error at gettimeofday()");
1115   return jlong(time.tv_sec) * 1000 + jlong(time.tv_usec / 1000);
1116 }
1117 
1118 void os::javaTimeSystemUTC(jlong &seconds, jlong &nanos) {
1119   timeval time;
1120   int status = gettimeofday(&time, NULL);
1121   assert(status != -1, "aix error at gettimeofday()");
1122   seconds = jlong(time.tv_sec);
1123   nanos = jlong(time.tv_usec) * 1000;
1124 }
1125 
1126 
1127 // We need to manually declare mread_real_time,
1128 // because IBM didn't provide a prototype in time.h.
1129 // (they probably only ever tested in C, not C++)
1130 extern "C"
1131 int mread_real_time(timebasestruct_t *t, size_t size_of_timebasestruct_t);
1132 
1133 jlong os::javaTimeNanos() {
1134   if (os::Aix::on_pase()) {
1135     Unimplemented();
1136     return 0;
1137   } else {
1138     // On AIX use the precision of processors real time clock
1139     // or time base registers.
1140     timebasestruct_t time;
1141     int rc;
1142 
1143     // If the CPU has a time register, it will be used and
1144     // we have to convert to real time first. After convertion we have following data:
1145     // time.tb_high [seconds since 00:00:00 UTC on 1.1.1970]
1146     // time.tb_low  [nanoseconds after the last full second above]


< prev index next >