Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/C/Firefox/dom/performance/tests/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 2 kB image not shown  

Quelle  test_worker_performance_now.js   Sprache: JAVA

 
function ok(a, msg) {
  dump("OK: " + !!a + " => " + a + ": " + msg + "\n");
  postMessage({ type: "status", status: !!a, msg: a + ": " + msg });
}

function workerTestDone() {
  postMessage({ type: "finish" });
}

ok(self.performance, "Performance object should exist.");
ok(
  typeof self.performance.now == "function",
  "Performance object should have a 'now' method."
);
var n = self.performance.now(),
  d = Date.now();
ok(n >= 0, "The value of now() should be equal to or greater than 0.");
ok(
  self.performance.now() >= n,
  "The value of now() should monotonically increase."
);

// Spin on setTimeout() until performance.now() increases. Due to recent
// security developments, the hr-time working group has not yet reached
// consensus on what the recommend minimum clock resolution should be:
// https://w3c.github.io/hr-time/#clock-resolution
// Since setTimeout might return too early/late, our goal is for
// performance.now() to increase before a 2 ms deadline rather than specific
// number of setTimeout(N) invocations.
// See bug 749894 (intermittent failures of this test)
setTimeout(checkAfterTimeout, 1);

var checks = 0;

function checkAfterTimeout() {
  checks++;
  var d2 = Date.now();
  var n2 = self.performance.now();

  // Spin on setTimeout() until performance.now() increases. Abort the test
  // if it runs for more than 2 ms or 50 timeouts.
  let elapsedTime = d2 - d;
  let elapsedPerf = n2 - n;
  if (elapsedPerf == 0 && elapsedTime < 2 && checks < 50) {
    setTimeout(checkAfterTimeout, 1);
    return;
  }

  // Our implementation provides 1 ms resolution (bug 1451790), but we
  // can't assert that elapsedPerf >= 1 ms because this worker test runs with
  // "privacy.reduceTimerPrecision" == false so performance.now() is not
  // limited to 1 ms resolution.
  ok(
    elapsedPerf > 0,
    `Loose - the value of now() should increase after 2ms. ` +
      `delta now(): ${elapsedPerf} ms`
  );

  // If we need more than 1 iteration, then either performance.now() resolution
  // is shorter than 1 ms or setTimeout() is returning too early.
  ok(
    checks == 1,
    `Strict - the value of now() should increase after one setTimeout. ` +
      `iters: ${checks}, dt: ${elapsedTime}, now(): ${n2}`
  );

  workerTestDone();
}

Messung V0.5
C=77 H=100 G=89

¤ Dauer der Verarbeitung: 0.1 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.