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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 COMPILE_ASSERT(sizeof(TimeTicks) == sizeof(Time), |
191 test_only_works_with_same_sizes); | 191 test_only_works_with_same_sizes); |
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 cases.push_back( | |
196 {reinterpret_cast<TestFunc>(&TraceTicks::Now), "TraceTicks::Now"}); | |
197 | 195 |
198 if (ThreadTicks::IsSupported()) { | 196 if (ThreadTicks::IsSupported()) { |
199 ThreadTicks::WaitUntilInitialized(); | 197 ThreadTicks::WaitUntilInitialized(); |
200 cases.push_back( | 198 cases.push_back( |
201 {reinterpret_cast<TestFunc>(&ThreadTicks::Now), "ThreadTicks::Now"}); | 199 {reinterpret_cast<TestFunc>(&ThreadTicks::Now), "ThreadTicks::Now"}); |
202 } | 200 } |
203 | 201 |
204 for (const auto& test_case : cases) { | 202 for (const auto& test_case : cases) { |
205 TimeTicks start = TimeTicks::Now(); | 203 TimeTicks start = TimeTicks::Now(); |
206 for (int index = 0; index < kLoops; index++) | 204 for (int index = 0; index < kLoops; index++) |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 static_cast<double>((converted_value - TimeTicks()).InMicroseconds()); | 287 static_cast<double>((converted_value - TimeTicks()).InMicroseconds()); |
290 EXPECT_NEAR(expected_microseconds_since_origin, | 288 EXPECT_NEAR(expected_microseconds_since_origin, |
291 converted_microseconds_since_origin, | 289 converted_microseconds_since_origin, |
292 1.0) | 290 1.0) |
293 << "ticks=" << ticks << ", to be converted via logic path: " | 291 << "ticks=" << ticks << ", to be converted via logic path: " |
294 << (ticks < Time::kQPCOverflowThreshold ? "FAST" : "SAFE"); | 292 << (ticks < Time::kQPCOverflowThreshold ? "FAST" : "SAFE"); |
295 } | 293 } |
296 } | 294 } |
297 | 295 |
298 } // namespace base | 296 } // namespace base |
OLD | NEW |