Bug 1220336 - Give HeapSnapshot.creationTime tests more slack for WinXP. r=jdescottes
authorNick Fitzgerald <fitzgen@gmail.com>
Tue, 19 Jan 2016 13:51:00 +0100
changeset 317690 4d222e447b87f0e66c609d1a57c6ad528cfca4d1
parent 317689 40a8ce2fe9fbb413314708062e3f561d46e061c0
child 317691 ccf0e6c22997217ead9384c36edd1e7b3177bdb2
push id1079
push userjlund@mozilla.com
push dateFri, 15 Apr 2016 21:02:33 +0000
treeherdermozilla-release@575fbf6786d5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes
bugs1220336
milestone46.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 1220336 - Give HeapSnapshot.creationTime tests more slack for WinXP. r=jdescottes These two tests have been intermittently failing on WinXP because the `Date.now()` timers only have a granularity of +/- 15 milliseconds on that platform. This commit ensures that we have a range of at least 30 milliseconds before and after taking the snapshot to ensure that the snapshot's timestamp will fit within the range.
devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_getCreationTime_01.js
devtools/shared/heapsnapshot/tests/unit/test_HeapSnapshot_creationTime_01.js
--- a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_getCreationTime_01.js
+++ b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_getCreationTime_01.js
@@ -1,37 +1,38 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Test that the HeapAnalyses{Client,Worker} can get a HeapSnapshot's
 // creation time.
 
-function waitForTenMilliseconds() {
+function waitForThirtyMilliseconds() {
   const start = Date.now();
-  while (Date.now() - start < 10) ;
+  while (Date.now() - start < 30) ;
 }
 
 function run_test() {
   run_next_test();
 }
 
 const BREAKDOWN = {
   by: "internalType",
   then: { by: "count", count: true, bytes: true }
 };
 
 add_task(function* () {
   const client = new HeapAnalysesClient();
   const start = Date.now() * 1000;
 
   // Because Date.now() is less precise than the snapshot's time stamp, give it
-  // a little bit of head room.
-  waitForTenMilliseconds();
+  // a little bit of head room. Additionally, WinXP's timers have a granularity
+  // of only +/-15 ms.
+  waitForThirtyMilliseconds();
   const snapshotFilePath = saveNewHeapSnapshot();
-  waitForTenMilliseconds();
+  waitForThirtyMilliseconds();
   const end = Date.now() * 1000;
 
   yield client.readHeapSnapshot(snapshotFilePath);
   ok(true, "Should have read the heap snapshot");
 
   let threw = false;
   try {
     yield client.getCreationTime("/not/a/real/path", {
@@ -40,13 +41,18 @@ add_task(function* () {
   } catch (_) {
     threw = true;
   }
   ok(threw, "getCreationTime should throw when snapshot does not exist");
 
   let time = yield client.getCreationTime(snapshotFilePath, {
     breakdown: BREAKDOWN
   });
+
+  dumpn("Start = " + start);
+  dumpn("End   = " + end);
+  dumpn("Time  = " + time);
+
   ok(time >= start, "creation time occurred after start");
   ok(time <= end, "creation time occurred before end");
 
   client.destroy();
 });
--- a/devtools/shared/heapsnapshot/tests/unit/test_HeapSnapshot_creationTime_01.js
+++ b/devtools/shared/heapsnapshot/tests/unit/test_HeapSnapshot_creationTime_01.js
@@ -1,27 +1,28 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // HeapSnapshot.prototype.creationTime returns the expected time.
 
-function waitForTenMilliseconds() {
+function waitForThirtyMilliseconds() {
   const start = Date.now();
-  while (Date.now() - start < 10) ;
+  while (Date.now() - start < 30) ;
 }
 
 function run_test() {
   const start = Date.now() * 1000;
   do_print("start                 = " + start);
 
   // Because Date.now() is less precise than the snapshot's time stamp, give it
-  // a little bit of head room.
-  waitForTenMilliseconds();
+  // a little bit of head room. Additionally, WinXP's timer only has granularity
+  // of +/- 15ms.
+  waitForThirtyMilliseconds();
   const path = ChromeUtils.saveHeapSnapshot({ runtime: true });
-  waitForTenMilliseconds();
+  waitForThirtyMilliseconds();
 
   const end = Date.now() * 1000;
   do_print("end                   = " + end);
 
   const snapshot = ChromeUtils.readHeapSnapshot(path);
   do_print("snapshot.creationTime = " + snapshot.creationTime);
 
   ok(snapshot.creationTime >= start);