| OLD | NEW | 
|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/time.h" | 9 #include "base/time.h" | 
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" | 
| 11 | 11 | 
|  | 12 using base::Time; | 
|  | 13 using base::TimeDelta; | 
|  | 14 using base::TimeTicks; | 
|  | 15 | 
| 12 namespace { | 16 namespace { | 
| 13 | 17 | 
| 14 class MockTimeTicks : public TimeTicks { | 18 class MockTimeTicks : public TimeTicks { | 
| 15  public: | 19  public: | 
| 16   static DWORD Ticker() { | 20   static DWORD Ticker() { | 
| 17     return static_cast<int>(InterlockedIncrement(&ticker_)); | 21     return static_cast<int>(InterlockedIncrement(&ticker_)); | 
| 18   } | 22   } | 
| 19 | 23 | 
| 20   static void InstallTicker() { | 24   static void InstallTicker() { | 
| 21     old_tick_function_ = SetMockTickFunction(&Ticker); | 25     old_tick_function_ = SetMockTickFunction(&Ticker); | 
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 185     TimeTicks start = TimeTicks::HighResNow(); | 189     TimeTicks start = TimeTicks::HighResNow(); | 
| 186     for (int index = 0; index < kLoops; index++) | 190     for (int index = 0; index < kLoops; index++) | 
| 187       cases[test_case].func(); | 191       cases[test_case].func(); | 
| 188     TimeTicks stop = TimeTicks::HighResNow(); | 192     TimeTicks stop = TimeTicks::HighResNow(); | 
| 189     EXPECT_LT((stop - start).InMilliseconds(), kMaxTime); | 193     EXPECT_LT((stop - start).InMilliseconds(), kMaxTime); | 
| 190     printf("%s: %1.2fus per call\n", cases[test_case].description, | 194     printf("%s: %1.2fus per call\n", cases[test_case].description, | 
| 191       (stop - start).InMillisecondsF() * 1000 / kLoops); | 195       (stop - start).InMillisecondsF() * 1000 / kLoops); | 
| 192     test_case++; | 196     test_case++; | 
| 193   } | 197   } | 
| 194 } | 198 } | 
| OLD | NEW | 
|---|