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

Quelle  test_file_repeated_add_delete.html   Sprache: HTML

 
 products/Sources/formale Sprachen/C/Firefox/dom/indexedDB/test/test_file_repeated_add_delete.html


<!--
  Any copyright is dedicated to the Public Domain.
  http://creativecommons.org/publicdomain/zero/1.0/
-->

<html>
<head>
  <title>Indexed Database Blob Add/Delete Stress Test</title>

  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>

  <script type="text/javascript">
  /*
   * This is a stress test which rapidly adds and deletes blobs in a row in
   * separate transactions. Internally, blobs are only removed when all memory
   * and database references drop to zero. At that point an asynchronous
   * delete operation is scheduled which removes the backing file from disk.
   * So the overall behavior and timing depends on cycle collection and
   * garbage collection. The main goal of this test is to make it more likely
   * that internal structures are accessed by multiple threads at the same
   * time, potentially discovering races or other issues.
   *
   * Note that the test needs to always create a new blob and a new
   * transaction, otherwise new backing files wouldn't be created due to
   * internal optimizations for de-duplication.
   */
  function* testSteps()
  {
    const READ_WRITE = "readwrite";

    const name = window.location.pathname;

    const objectStoreName = "Blobs";

    {
      const request = indexedDB.open(name, 1);
      request.onerror = errorHandler;
      request.onupgradeneeded = grabEventAndContinueHandler;
      request.onsuccess = grabEventAndContinueHandler;
    }

    {
      const event = yield undefined;

      is(event.type, "upgradeneeded""Got correct event type");

      const db = event.target.result;
      db.onerror = errorHandler;

      const objectStore = db.createObjectStore(objectStoreName, {});

      objectStore.add(getRandomBlob(1), 1);
    }

    {
      const event = yield undefined;

      is(event.type, "success""Got correct event type");

      const db = event.target.result;
      db.onerror = errorHandler;

      let index = 1;

      function doWork() {
        const transaction = db.transaction([objectStoreName], READ_WRITE);

        const objectStore = transaction.objectStore(objectStoreName);

        const deleteRequest = objectStore.delete(index);
        deleteRequest.onsuccess = function () {
          index++;

          const addRequest = objectStore.add(getRandomBlob(1), index);
          addRequest.onsuccess = function () {
            if (index < 1000) {
              doWork();
            } else {
              continueToNextStep();
            }
          };
        };
      }

      doWork();

      yield undefined;
    }

    finishTest();
  }
  </script>
  <script type="text/javascript" src="file.js"></script>
  <script type="text/javascript" src="helpers.js"></script>

</head>

<body onload="runTest();"></body>

</html>

Messung V0.5
C=92 H=96 G=93

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© 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.