| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/threading/platform_thread.h" | 9 #include "base/threading/platform_thread.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 // Note: This is a somewhat arbitrary test. | 171 // Note: This is a somewhat arbitrary test. |
| 172 const int kLoops = 10000; | 172 const int kLoops = 10000; |
| 173 // Due to the fact that these run on bbots, which are horribly slow, | 173 // Due to the fact that these run on bbots, which are horribly slow, |
| 174 // we can't really make any guarantees about minimum runtime. | 174 // we can't really make any guarantees about minimum runtime. |
| 175 // Really, we want these to finish in ~10ms, and that is generous. | 175 // Really, we want these to finish in ~10ms, and that is generous. |
| 176 const int kMaxTime = 35; // Maximum acceptible milliseconds for test. | 176 const int kMaxTime = 35; // Maximum acceptible milliseconds for test. |
| 177 | 177 |
| 178 typedef TimeTicks (*TestFunc)(); | 178 typedef TimeTicks (*TestFunc)(); |
| 179 struct TestCase { | 179 struct TestCase { |
| 180 TestFunc func; | 180 TestFunc func; |
| 181 char *description; | 181 const char *description; |
| 182 }; | 182 }; |
| 183 // Cheating a bit here: assumes sizeof(TimeTicks) == sizeof(Time) | 183 // Cheating a bit here: assumes sizeof(TimeTicks) == sizeof(Time) |
| 184 // in order to create a single test case list. | 184 // in order to create a single test case list. |
| 185 COMPILE_ASSERT(sizeof(TimeTicks) == sizeof(Time), | 185 COMPILE_ASSERT(sizeof(TimeTicks) == sizeof(Time), |
| 186 test_only_works_with_same_sizes); | 186 test_only_works_with_same_sizes); |
| 187 TestCase cases[] = { | 187 TestCase cases[] = { |
| 188 { reinterpret_cast<TestFunc>(Time::Now), "Time::Now" }, | 188 { reinterpret_cast<TestFunc>(Time::Now), "Time::Now" }, |
| 189 { TimeTicks::Now, "TimeTicks::Now" }, | 189 { TimeTicks::Now, "TimeTicks::Now" }, |
| 190 { TimeTicks::HighResNow, "TimeTicks::HighResNow" }, | 190 { TimeTicks::HighResNow, "TimeTicks::HighResNow" }, |
| 191 { NULL, "" } | 191 { NULL, "" } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 total_drift += drift_microseconds; | 233 total_drift += drift_microseconds; |
| 234 } | 234 } |
| 235 | 235 |
| 236 // Sanity check. We expect some time drift to occur, especially across | 236 // Sanity check. We expect some time drift to occur, especially across |
| 237 // the number of iterations we do. | 237 // the number of iterations we do. |
| 238 EXPECT_LT(0, total_drift); | 238 EXPECT_LT(0, total_drift); |
| 239 | 239 |
| 240 printf("average time drift in microseconds: %lld\n", | 240 printf("average time drift in microseconds: %lld\n", |
| 241 total_drift / kIterations); | 241 total_drift / kIterations); |
| 242 } | 242 } |
| OLD | NEW |