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

Unified Diff: base/time_win_unittest.cc

Issue 3387011: The submillisecond test was broken in at least two ways. First, the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/time_win.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/time_win_unittest.cc
===================================================================
--- base/time_win_unittest.cc (revision 59966)
+++ base/time_win_unittest.cc (working copy)
@@ -108,27 +108,29 @@
}
}
-// Flaky, http://crbug.com/42850.
-TEST(TimeTicks, FLAKY_SubMillisecondTimers) {
- // Loop for a bit getting timers quickly. We want to
- // see at least one case where we get a new sample in
- // less than one millisecond.
+TEST(TimeTicks, SubMillisecondTimers) {
+ // HighResNow doesn't work on some systems. Since the product still works
+ // even if it doesn't work, it makes this entire test questionable.
+ if (!TimeTicks::IsHighResClockWorking())
+ return;
+
+ const int kRetries = 1000;
bool saw_submillisecond_timer = false;
- int64 min_timer = 1000;
- TimeTicks last_time = TimeTicks::HighResNow();
+
+ // Run kRetries attempts to see a sub-millisecond timer.
Paweł Hajdan Jr. 2010/09/22 09:35:32 This test has still potential for flakiness. What
Mike Belshe 2010/09/22 21:58:48 Unfortunately, I don't think it helps. In this ca
for (int index = 0; index < 1000; index++) {
- TimeTicks now = TimeTicks::HighResNow();
- TimeDelta delta = now - last_time;
- if (delta.InMicroseconds() > 0 &&
- delta.InMicroseconds() < 1000) {
- if (min_timer > delta.InMicroseconds())
- min_timer = delta.InMicroseconds();
+ TimeTicks last_time = TimeTicks::HighResNow();
+ TimeDelta delta;
+ // Spin until the clock changes a little
Paweł Hajdan Jr. 2010/09/22 09:35:32 nit: Dot at the end, and explain why.
Mike Belshe 2010/09/22 21:58:48 Done.
+ do {
+ delta = TimeTicks::HighResNow() - last_time;
+ } while (delta.InMicroseconds() == 0);
+ if (delta.InMicroseconds() < 1000) {
saw_submillisecond_timer = true;
+ break;
}
- last_time = now;
}
EXPECT_TRUE(saw_submillisecond_timer);
- printf("Min timer is: %ldus\n", static_cast<long>(min_timer));
}
TEST(TimeTicks, TimeGetTimeCaps) {
@@ -230,4 +232,4 @@
printf("average time drift in microseconds: %lld\n",
total_drift / kIterations);
-}
+}
« no previous file with comments | « base/time_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698