Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  test_table_locks.js   Sprache: JAVA

 
/**
 * Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/
 */


const dbName = "window" in this ? window.location.pathname : "test";
const dbVersion = 1;
const objName1 = "o1";
const objName2 = "o2";
const idxName1 = "i1";
const idxName2 = "i2";
const idxKeyPathProp = "idx";
const objDataProp = "data";
const objData = "1234567890";
const objDataCount = 5;
const loopCount = 100;

/* exported testGenerator */
var testGenerator = testSteps();

function* testSteps() {
  let req = indexedDB.open(dbName, dbVersion);
  req.onerror = errorHandler;
  req.onupgradeneeded = grabEventAndContinueHandler;
  req.onsuccess = grabEventAndContinueHandler;

  let event = yield undefined;

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

  let db = event.target.result;

  let objectStore1 = db.createObjectStore(objName1);
  objectStore1.createIndex(idxName1, idxKeyPathProp);

  let objectStore2 = db.createObjectStore(objName2);
  objectStore2.createIndex(idxName2, idxKeyPathProp);

  for (let i = 0; i < objDataCount; i++) {
    var data = {};
    data[objDataProp] = objData;
    data[idxKeyPathProp] = objDataCount - i - 1;

    objectStore1.add(data, i);
    objectStore2.add(data, i);
  }

  event = yield undefined;

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

  doReadOnlyTransaction(db, 0, loopCount);
  doReadWriteTransaction(db, 0, loopCount);

  // Wait for readonly and readwrite transaction loops to complete.
  yield undefined;
  yield undefined;

  finishTest();
}

function doReadOnlyTransaction(db, key, remaining) {
  if (!remaining) {
    info("Finished all readonly transactions");
    continueToNextStep();
    return;
  }

  info(
    "Starting readonly transaction for key " +
      key +
      ", " +
      remaining +
      " loops left"
  );

  let objectStore = db.transaction(objName1, "readonly").objectStore(objName1);
  let index = objectStore.index(idxName1);

  index.openKeyCursor(key, "prev").onsuccess = function (event) {
    let cursor = event.target.result;
    ok(cursor, "Got readonly cursor");

    objectStore.get(cursor.primaryKey).onsuccess = function () {
      if (++key == objDataCount) {
        key = 0;
      }
      doReadOnlyTransaction(db, key, remaining - 1);
    };
  };
}

function doReadWriteTransaction(db, key, remaining) {
  if (!remaining) {
    info("Finished all readwrite transactions");
    continueToNextStep();
    return;
  }

  info(
    "Starting readwrite transaction for key " +
      key +
      ", " +
      remaining +
      " loops left"
  );

  let objectStore = db.transaction(objName2, "readwrite").objectStore(objName2);
  objectStore.openCursor(key).onsuccess = function (event) {
    let cursor = event.target.result;
    ok(cursor, "Got readwrite cursor");

    let value = cursor.value;
    value[idxKeyPathProp]++;

    cursor.update(value).onsuccess = function () {
      if (++key == objDataCount) {
        key = 0;
      }
      doReadWriteTransaction(db, key, remaining - 1);
    };
  };
}

Messung V0.5
C=89 H=95 G=91

¤ Dauer der Verarbeitung: 0.23 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.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge