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

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

Issue 2106243002: Enable ThreadTicks on Windows. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix test 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 unified diff | Download patch
« no previous file with comments | « src/base/platform/time.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/base/platform/time.h" 5 #include "src/base/platform/time.h"
6 6
7 #if V8_OS_MACOSX 7 #if V8_OS_MACOSX
8 #include <mach/mach_time.h> 8 #include <mach/mach_time.h>
9 #endif 9 #endif
10 #if V8_OS_POSIX 10 #if V8_OS_POSIX
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 EXPECT_GE(normal_ticks, previous_normal_ticks); 179 EXPECT_GE(normal_ticks, previous_normal_ticks);
180 EXPECT_GE((normal_ticks - previous_normal_ticks).InMicroseconds(), 0); 180 EXPECT_GE((normal_ticks - previous_normal_ticks).InMicroseconds(), 0);
181 EXPECT_GE(highres_ticks, previous_highres_ticks); 181 EXPECT_GE(highres_ticks, previous_highres_ticks);
182 EXPECT_GE((highres_ticks - previous_highres_ticks).InMicroseconds(), 0); 182 EXPECT_GE((highres_ticks - previous_highres_ticks).InMicroseconds(), 0);
183 previous_normal_ticks = normal_ticks; 183 previous_normal_ticks = normal_ticks;
184 previous_highres_ticks = highres_ticks; 184 previous_highres_ticks = highres_ticks;
185 } 185 }
186 } 186 }
187 187
188 188
189 // Disable on windows until it is implemented.
190 #if V8_OS_ANDROID 189 #if V8_OS_ANDROID
191 #define MAYBE_ThreadNow DISABLED_ThreadNow 190 #define MAYBE_ThreadNow DISABLED_ThreadNow
192 #else 191 #else
193 #define MAYBE_ThreadNow ThreadNow 192 #define MAYBE_ThreadNow ThreadNow
194 #endif 193 #endif
195 TEST(ThreadTicks, MAYBE_ThreadNow) { 194 TEST(ThreadTicks, MAYBE_ThreadNow) {
196 if (ThreadTicks::IsSupported()) { 195 if (ThreadTicks::IsSupported()) {
196 ThreadTicks::WaitUntilInitialized();
197 TimeTicks begin = TimeTicks::Now(); 197 TimeTicks begin = TimeTicks::Now();
198 ThreadTicks begin_thread = ThreadTicks::Now(); 198 ThreadTicks begin_thread = ThreadTicks::Now();
199 // Make sure that ThreadNow value is non-zero. 199 // Make sure that ThreadNow value is non-zero.
200 EXPECT_GT(begin_thread, ThreadTicks()); 200 EXPECT_GT(begin_thread, ThreadTicks());
201 // Sleep for 10 milliseconds to get the thread de-scheduled. 201 // Sleep for 10 milliseconds to get the thread de-scheduled.
202 OS::Sleep(base::TimeDelta::FromMilliseconds(10)); 202 OS::Sleep(base::TimeDelta::FromMilliseconds(10));
203 ThreadTicks end_thread = ThreadTicks::Now(); 203 ThreadTicks end_thread = ThreadTicks::Now();
204 TimeTicks end = TimeTicks::Now(); 204 TimeTicks end = TimeTicks::Now();
205 TimeDelta delta = end - begin; 205 TimeDelta delta = end - begin;
206 TimeDelta delta_thread = end_thread - begin_thread; 206 TimeDelta delta_thread = end_thread - begin_thread;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 // const int kMaxTime = 35; // Maximum acceptible milliseconds for test. 252 // const int kMaxTime = 35; // Maximum acceptible milliseconds for test.
253 // EXPECT_LT((stop - start).InMilliseconds(), kMaxTime); 253 // EXPECT_LT((stop - start).InMilliseconds(), kMaxTime);
254 printf("%s: %1.2fus per call\n", test_case.description, 254 printf("%s: %1.2fus per call\n", test_case.description,
255 (stop - start).InMillisecondsF() * 1000 / kLoops); 255 (stop - start).InMillisecondsF() * 1000 / kLoops);
256 } 256 }
257 } 257 }
258 #endif // V8_OS_WIN 258 #endif // V8_OS_WIN
259 259
260 } // namespace base 260 } // namespace base
261 } // namespace v8 261 } // namespace v8
OLDNEW
« 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