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

Side by Side Diff: base/time/time_win_unittest.cc

Issue 2951413003: Add UMA for High Resolution Timer Usage (Closed)
Patch Set: Removed NaCl changes Created 3 years, 5 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
« no previous file with comments | « base/time/time_win.cc ('k') | base/timer/hi_res_timer_manager.h » ('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) 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 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <cmath> 10 #include <cmath>
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 << "ticks=" << ticks << ", to be converted via logic path: " 293 << "ticks=" << ticks << ", to be converted via logic path: "
294 << (ticks < Time::kQPCOverflowThreshold ? "FAST" : "SAFE"); 294 << (ticks < Time::kQPCOverflowThreshold ? "FAST" : "SAFE");
295 } 295 }
296 } 296 }
297 297
298 TEST(TimeDelta, ConstexprInitialization) { 298 TEST(TimeDelta, ConstexprInitialization) {
299 // Make sure that TimeDelta works around crbug.com/635974 299 // Make sure that TimeDelta works around crbug.com/635974
300 EXPECT_EQ(kExpectedDeltaInMilliseconds, kConstexprTimeDelta.InMilliseconds()); 300 EXPECT_EQ(kExpectedDeltaInMilliseconds, kConstexprTimeDelta.InMilliseconds());
301 } 301 }
302 302
303 TEST(HighResolutionTimer, GetUsage) {
304 EXPECT_EQ(0.0, Time::GetHighResolutionTimerUsage());
305
306 Time::ResetHighResolutionTimerUsage();
307
308 // 0% usage since the timer isn't activated regardless of how much time has
309 // elapsed.
310 EXPECT_EQ(0.0, Time::GetHighResolutionTimerUsage());
311 Sleep(10);
312 EXPECT_EQ(0.0, Time::GetHighResolutionTimerUsage());
313
314 Time::ActivateHighResolutionTimer(true);
315 Time::ResetHighResolutionTimerUsage();
316
317 Sleep(20);
318 // 100% usage since the timer has been activated entire time.
319 EXPECT_EQ(100.0, Time::GetHighResolutionTimerUsage());
320
321 Time::ActivateHighResolutionTimer(false);
322 Sleep(20);
323 double usage1 = Time::GetHighResolutionTimerUsage();
324 // usage1 should be about 50%.
325 EXPECT_LT(usage1, 100.0);
326 EXPECT_GT(usage1, 0.0);
327
328 Time::ActivateHighResolutionTimer(true);
329 Sleep(10);
330 Time::ActivateHighResolutionTimer(false);
331 double usage2 = Time::GetHighResolutionTimerUsage();
332 // usage2 should be about 60%.
333 EXPECT_LT(usage2, 100.0);
334 EXPECT_GT(usage2, usage1);
335
336 Time::ResetHighResolutionTimerUsage();
337 EXPECT_EQ(0.0, Time::GetHighResolutionTimerUsage());
338 }
339
303 } // namespace base 340 } // namespace base
OLDNEW
« no previous file with comments | « base/time/time_win.cc ('k') | base/timer/hi_res_timer_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698