Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1461)

Unified Diff: src/base/platform/time.cc

Issue 2174003002: AIX: Fix to get more accurate Thread's CPU time (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fixed incorrect indentation Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/base/platform/time.cc
diff --git a/src/base/platform/time.cc b/src/base/platform/time.cc
index e7867e07955a1094ebd6135210f6b473cfd73339..76a820955fb98d6d2f8bbac3b03f72bfdc579534 100644
--- a/src/base/platform/time.cc
+++ b/src/base/platform/time.cc
@@ -56,6 +56,17 @@ int64_t ComputeThreadTicks() {
V8_INLINE int64_t ClockNow(clockid_t clk_id) {
#if (defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0) || \
defined(V8_OS_BSD) || defined(V8_OS_ANDROID)
+// On AIX clock_gettime for CLOCK_THREAD_CPUTIME_ID outputs time with
+// resolution of 10ms. thread_cputime API provides the time in ns
+#if defined(V8_OS_AIX)
+ thread_cputime_t tc;
+ if (clk_id == CLOCK_THREAD_CPUTIME_ID) {
+ if (thread_cputime(-1, &tc) != 0) {
+ UNREACHABLE();
+ return 0;
+ }
+ }
+#endif
struct timespec ts;
if (clock_gettime(clk_id, &ts) != 0) {
UNREACHABLE();
@@ -63,7 +74,15 @@ V8_INLINE int64_t ClockNow(clockid_t clk_id) {
}
v8::base::internal::CheckedNumeric<int64_t> result(ts.tv_sec);
result *= v8::base::Time::kMicrosecondsPerSecond;
+#if defined(V8_OS_AIX)
+ if (clk_id == CLOCK_THREAD_CPUTIME_ID) {
+ result += (tc.stime / v8::base::Time::kNanosecondsPerMicrosecond);
+ } else {
+ result += (ts.tv_nsec / v8::base::Time::kNanosecondsPerMicrosecond);
+ }
+#else
result += (ts.tv_nsec / v8::base::Time::kNanosecondsPerMicrosecond);
+#endif
return result.ValueOrDie();
#else // Monotonic clock not supported.
return 0;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698