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

Side by Side Diff: base/time_win_unittest.cc

Issue 6001010: Move platform_thread to base/threading and put in the base namespace. I left ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « base/time_unittest.cc ('k') | base/timer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium 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 <windows.h> 5 #include <windows.h>
6 #include <mmsystem.h> 6 #include <mmsystem.h>
7 #include <process.h> 7 #include <process.h>
8 8
9 #include "base/platform_thread.h" 9 #include "base/threading/platform_thread.h"
10 #include "base/time.h" 10 #include "base/time.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 using base::Time; 13 using base::Time;
14 using base::TimeDelta; 14 using base::TimeDelta;
15 using base::TimeTicks; 15 using base::TimeTicks;
16 16
17 namespace { 17 namespace {
18 18
19 class MockTimeTicks : public TimeTicks { 19 class MockTimeTicks : public TimeTicks {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 213
214 for (int i = 0; i < kIterations; ++i) { 214 for (int i = 0; i < kIterations; ++i) {
215 int64 drift_microseconds = TimeTicks::GetQPCDriftMicroseconds(); 215 int64 drift_microseconds = TimeTicks::GetQPCDriftMicroseconds();
216 216
217 // Make sure the drift never exceeds our limit. 217 // Make sure the drift never exceeds our limit.
218 EXPECT_LT(drift_microseconds, 50000); 218 EXPECT_LT(drift_microseconds, 50000);
219 219
220 // Sleep for a few milliseconds (note that it means 1000 microseconds). 220 // Sleep for a few milliseconds (note that it means 1000 microseconds).
221 // If we check the drift too frequently, it's going to increase 221 // If we check the drift too frequently, it's going to increase
222 // monotonically, making our measurement less realistic. 222 // monotonically, making our measurement less realistic.
223 PlatformThread::Sleep((i % 2 == 0) ? 1 : 2); 223 base::PlatformThread::Sleep((i % 2 == 0) ? 1 : 2);
224 224
225 total_drift += drift_microseconds; 225 total_drift += drift_microseconds;
226 } 226 }
227 227
228 // Sanity check. We expect some time drift to occur, especially across 228 // Sanity check. We expect some time drift to occur, especially across
229 // the number of iterations we do. However, if the QPC is disabled, this 229 // the number of iterations we do. However, if the QPC is disabled, this
230 // is not measuring anything (drift is zero in that case). 230 // is not measuring anything (drift is zero in that case).
231 EXPECT_LT(0, total_drift); 231 EXPECT_LT(0, total_drift);
232 232
233 printf("average time drift in microseconds: %lld\n", 233 printf("average time drift in microseconds: %lld\n",
234 total_drift / kIterations); 234 total_drift / kIterations);
235 } 235 }
OLDNEW
« no previous file with comments | « base/time_unittest.cc ('k') | base/timer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698