Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Wrapped transaction read inside a closure for correctness
  • Loading branch information
Parashuram committed Apr 17, 2013
1 parent 3cf525e commit f8f88af
Showing 1 changed file with 27 additions and 24 deletions.
51 changes: 27 additions & 24 deletions perf/tests/3_TransactionRead.js
Expand Up @@ -41,16 +41,16 @@
var db = req.result;
var transaction = db.transaction(['Table1'], 'readonly');
var objStore = transaction.objectStore('Table1');
//console.log("Database opened");
for (var i = 0; i < 1000; i++) {
//console.log('Single Transaction - reading ', i)
var readReq = objStore.get(i);
readReq.onsuccess = readReq.onerror = function() {
if (++readCount >= 999) {
db.close()
deferred.resolve();
(function(i) {
var readReq = objStore.get(i);
readReq.onsuccess = readReq.onerror = function() {
if (++readCount >= 999) {
db.close()
deferred.resolve();
}
}
}
}(i));
}

};
Expand All @@ -68,14 +68,15 @@
var transaction = db.transaction(['Table1'], 'readonly');
var objStore = transaction.objectStore('Table1');
for (var j = 0; j < 100; j++) {
//console.log('Transactions Sets - Reading ', i)
var readReq = objStore.get(i);
readReq.onsuccess = readReq.onerror = function() {
if (++readCount >= 999) {
db.close();
deferred.resolve();
(function(i) {
var readReq = objStore.get(i);
readReq.onsuccess = readReq.onerror = function() {
if (++readCount >= 999) {
db.close();
deferred.resolve();
}
}
}
}(i));
}

}
Expand All @@ -91,16 +92,18 @@
var db = req.result;
//console.log("Database opened");
for (var i = 0; i < 1000; i++) {
var transaction = db.transaction(['Table1'], 'readonly');
var objStore = transaction.objectStore('Table1');
//console.log('Multiple transactions - Reading ', i)
var readReq = objStore.get(i);
readReq.onsuccess = readReq.onerror = function() {
if (++readCount >= 999) {
db.close();
deferred.resolve();
(function(i) {
var transaction = db.transaction(['Table1'], 'readonly');
var objStore = transaction.objectStore('Table1');
//console.log('Multiple transactions - Reading ', i)
var readReq = objStore.get(i);
readReq.onsuccess = readReq.onerror = function() {
if (++readCount >= 999) {
db.close();
deferred.resolve();
}
}
}
}(i));
}
};
req.onerror = function() {
Expand Down

0 comments on commit f8f88af

Please sign in to comment.