Sample code:
let request = self.indexedDB.open('db', 1);
console.log(String(Date.now()) + ' after open');
request.onsuccess = (event) => {
console.log(String(Date.now()) + ' open success');
const db = event.target.result;
const oneCycle = () => {
return new Promise(resolve => {
console.log(String(Date.now()) + ' start retrieving value');
const transaction = db.transaction('store').objectStore('store');
transaction.get('key').onsuccess = (event) => {
console.log(String(Date.now()) + ' got value: ' + event.target.result);
resolve();
};
});
};
let promise = Promise.resolve();
for (let i = 0; i < 50; i++)
promise = promise.then(oneCycle);
});
It's common to see 20-30ms between 'start retrieving value' and 'got value'; within a tx the timing is only 2ms per query (which is still high)
This is strange as there should be nothing holding up the tx from starting immediately as it's read-only.
Comment 1 by jsb...@chromium.org
, Sep 28 2016904 bytes
904 bytes View Download