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 <cmath> | 9 #include <cmath> |
10 #include <limits> | 10 #include <limits> |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 // Note: This is a somewhat arbitrary test. | 180 // Note: This is a somewhat arbitrary test. |
181 const int kLoops = 10000; | 181 const int kLoops = 10000; |
182 | 182 |
183 typedef TimeTicks (*TestFunc)(); | 183 typedef TimeTicks (*TestFunc)(); |
184 struct TestCase { | 184 struct TestCase { |
185 TestFunc func; | 185 TestFunc func; |
186 const char *description; | 186 const char *description; |
187 }; | 187 }; |
188 // Cheating a bit here: assumes sizeof(TimeTicks) == sizeof(Time) | 188 // Cheating a bit here: assumes sizeof(TimeTicks) == sizeof(Time) |
189 // in order to create a single test case list. | 189 // in order to create a single test case list. |
190 COMPILE_ASSERT(sizeof(TimeTicks) == sizeof(Time), | 190 static_assert(sizeof(TimeTicks) == sizeof(Time), |
191 test_only_works_with_same_sizes); | 191 "TimeTicks and Time must be the same size"); |
192 std::vector<TestCase> cases; | 192 std::vector<TestCase> cases; |
193 cases.push_back({reinterpret_cast<TestFunc>(&Time::Now), "Time::Now"}); | 193 cases.push_back({reinterpret_cast<TestFunc>(&Time::Now), "Time::Now"}); |
194 cases.push_back({&TimeTicks::Now, "TimeTicks::Now"}); | 194 cases.push_back({&TimeTicks::Now, "TimeTicks::Now"}); |
195 | 195 |
196 if (ThreadTicks::IsSupported()) { | 196 if (ThreadTicks::IsSupported()) { |
197 ThreadTicks::WaitUntilInitialized(); | 197 ThreadTicks::WaitUntilInitialized(); |
198 cases.push_back( | 198 cases.push_back( |
199 {reinterpret_cast<TestFunc>(&ThreadTicks::Now), "ThreadTicks::Now"}); | 199 {reinterpret_cast<TestFunc>(&ThreadTicks::Now), "ThreadTicks::Now"}); |
200 } | 200 } |
201 | 201 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 static_cast<double>((converted_value - TimeTicks()).InMicroseconds()); | 287 static_cast<double>((converted_value - TimeTicks()).InMicroseconds()); |
288 EXPECT_NEAR(expected_microseconds_since_origin, | 288 EXPECT_NEAR(expected_microseconds_since_origin, |
289 converted_microseconds_since_origin, | 289 converted_microseconds_since_origin, |
290 1.0) | 290 1.0) |
291 << "ticks=" << ticks << ", to be converted via logic path: " | 291 << "ticks=" << ticks << ", to be converted via logic path: " |
292 << (ticks < Time::kQPCOverflowThreshold ? "FAST" : "SAFE"); | 292 << (ticks < Time::kQPCOverflowThreshold ? "FAST" : "SAFE"); |
293 } | 293 } |
294 } | 294 } |
295 | 295 |
296 } // namespace base | 296 } // namespace base |
OLD | NEW |