diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-04 22:17:18 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-04 22:17:18 +0000 |
commit | 0b2a2f4907087f36cd185bacbd685930eb7cbb31 (patch) | |
tree | fa5911a40aa50c3272b12d24ccabc98b1c4b9472 /base/time_win_unittest.cc | |
parent | ec707950fa24bcda70344b07f88f619117343a4f (diff) | |
download | chromium_src-0b2a2f4907087f36cd185bacbd685930eb7cbb31.zip chromium_src-0b2a2f4907087f36cd185bacbd685930eb7cbb31.tar.gz chromium_src-0b2a2f4907087f36cd185bacbd685930eb7cbb31.tar.bz2 |
GTTF: Avoid assertion failures caused by clock drift.
Instead, we add a test dedicated to verifying the QPC
time drift. Otherwise the assertion is being flakily hit
in unrelated tests, which crashes the entire test binary.
With a dedicated test, we still have necessary monitoring,
but it's in one place.
TEST=base_unittests, net_unittests (stop crashing)
BUG=none
Review URL: http://codereview.chromium.org/3082014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54978 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/time_win_unittest.cc')
-rw-r--r-- | base/time_win_unittest.cc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/base/time_win_unittest.cc b/base/time_win_unittest.cc index aa39478..26a9784 100644 --- a/base/time_win_unittest.cc +++ b/base/time_win_unittest.cc @@ -6,6 +6,7 @@ #include <mmsystem.h> #include <process.h> +#include "base/platform_thread.h" #include "base/time.h" #include "testing/gtest/include/gtest/gtest.h" @@ -203,3 +204,30 @@ TEST(TimeTicks, TimerPerformance) { test_case++; } } + +TEST(TimeTicks, Drift) { + const int kIterations = 100; + int64 total_drift = 0; + + for (int i = 0; i < kIterations; ++i) { + int64 drift_microseconds = TimeTicks::GetQPCDriftMicroseconds(); + + // Make sure the drift never exceeds our limit. + EXPECT_LT(drift_microseconds, 50000); + + // Sleep for a few milliseconds (note that it means 1000 microseconds). + // If we check the drift too frequently, it's going to increase + // monotonically, making our measurement less realistic. + PlatformThread::Sleep((i % 2 == 0) ? 1 : 2); + + total_drift += drift_microseconds; + } + + // Sanity check. We expect some time drift to occur, especially across + // the number of iterations we do. However, if the QPC is disabled, this + // is not measuring anything (drift is zero in that case). + EXPECT_LT(0, total_drift); + + printf("average time drift in microseconds: %lld\n", + total_drift / kIterations); +}
\ No newline at end of file |