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

Unified Diff: test/unittests/base/platform/time-unittest.cc

Issue 1966183003: [Reland] Implement CPU time for OS X and POSIX. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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 | « src/base/platform/time.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/base/platform/time-unittest.cc
diff --git a/test/unittests/base/platform/time-unittest.cc b/test/unittests/base/platform/time-unittest.cc
index b3bfbab3190506029b0243359520f913121cce59..784fbf842d92b39df06ed568294c4346e7a4d178 100644
--- a/test/unittests/base/platform/time-unittest.cc
+++ b/test/unittests/base/platform/time-unittest.cc
@@ -16,6 +16,7 @@
#endif
#include "src/base/platform/elapsed-timer.h"
+#include "src/base/platform/platform.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace v8 {
@@ -182,5 +183,32 @@ TEST(TimeTicks, IsMonotonic) {
}
}
+
+// Disable on windows until it is implemented.
+#if V8_OS_ANDROID || V8_OS_WIN
+#define MAYBE_ThreadNow DISABLED_ThreadNow
+#else
+#define MAYBE_ThreadNow ThreadNow
+#endif
+TEST(ThreadTicks, MAYBE_ThreadNow) {
+ if (ThreadTicks::IsSupported()) {
+ TimeTicks begin = TimeTicks::Now();
+ ThreadTicks begin_thread = ThreadTicks::Now();
+ // Make sure that ThreadNow value is non-zero.
+ EXPECT_GT(begin_thread, ThreadTicks());
+ // Sleep for 10 milliseconds to get the thread de-scheduled.
+ OS::Sleep(base::TimeDelta::FromMilliseconds(10));
+ ThreadTicks end_thread = ThreadTicks::Now();
+ TimeTicks end = TimeTicks::Now();
+ TimeDelta delta = end - begin;
+ TimeDelta delta_thread = end_thread - begin_thread;
+ // Make sure that some thread time have elapsed.
+ EXPECT_GT(delta_thread.InMicroseconds(), 0);
+ // But the thread time is at least 9ms less than clock time.
+ TimeDelta difference = delta - delta_thread;
+ EXPECT_GE(difference.InMicroseconds(), 9000);
+ }
+}
+
} // namespace base
} // namespace v8
« no previous file with comments | « src/base/platform/time.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698