Bug 1546012 - Avoid slow sleeps on Android in TestSPSCQueue; r=padenot
authorGeoff Brown <gbrown@mozilla.com>
Tue, 23 Apr 2019 13:39:36 +0000
changeset 470492 4e29ffe20754681357353e3be5521f0cb200f544
parent 470491 c9e17214f445d48114913ea9f0c00f334edac55a
child 470493 e56e63264f65972f66905dd8893eb549984ffce9
push id35906
push useraciure@mozilla.com
push dateTue, 23 Apr 2019 22:14:56 +0000
treeherdermozilla-central@0ce3633f8b80 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1546012
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1546012 - Avoid slow sleeps on Android in TestSPSCQueue; r=padenot Reducing the sleep to 0 on Android results in a dramatic reduction in run time, and the test passes consistently. Differential Revision: https://phabricator.services.mozilla.com/D28296
mfbt/tests/TestSPSCQueue.cpp
--- a/mfbt/tests/TestSPSCQueue.cpp
+++ b/mfbt/tests/TestSPSCQueue.cpp
@@ -75,21 +75,23 @@ void TestRing(int capacity) {
     PodZero(seq.get(), BLOCK_SIZE);
     rv = buf.Dequeue(seq.get(), BLOCK_SIZE);
     MOZ_RELEASE_ASSERT(rv == BLOCK_SIZE);
     checker.Check(seq.get(), BLOCK_SIZE);
   }
 }
 
 void Delay() {
-  // On Windows, the timer resolution is so bad that, even if we used
-  // `timeBeginPeriod(1)`, any nonzero sleep from the test's inner loops
+  // On Windows and x86 Android, the timer resolution is so bad that, even if
+  // we used `timeBeginPeriod(1)`, any nonzero sleep from the test's inner loops
   // would make this program take far too long.
 #ifdef _WIN32
   Sleep(0);
+#elif defined(ANDROID)
+  std::this_thread::sleep_for(std::chrono::microseconds(0));
 #else
   std::this_thread::sleep_for(std::chrono::microseconds(10));
 #endif
 }
 
 template <typename T>
 void TestRingMultiThread(int capacity) {
   SPSCQueue<T> buf(capacity);