Skip to content
Permalink
Browse files
More IndexedDB perf tests.
https://bugs.webkit.org/show_bug.cgi?id=165634

Reviewed by Sam Weinig.

* IndexedDB/index-multientry.html:
* IndexedDB/large-number-of-inserts-responsiveness.html: Added.
* IndexedDB/large-number-of-inserts.html: Added.
* IndexedDB/objectstore-cursor.html: Added.

* resources/runner.js: Add "track responsiveness" functionality to PerfTestRunner.


Canonical link: https://commits.webkit.org/183328@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@209672 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
beidson committed Dec 10, 2016
1 parent 5db3b12 commit d38a43a46508c82d3e1e4bfc92f93230961e8d83
Showing 6 changed files with 295 additions and 5 deletions.
@@ -1,3 +1,17 @@
2016-12-10 Brady Eidson <beidson@apple.com>

More IndexedDB perf tests.
https://bugs.webkit.org/show_bug.cgi?id=165634

Reviewed by Sam Weinig.

* IndexedDB/index-multientry.html:
* IndexedDB/large-number-of-inserts-responsiveness.html: Added.
* IndexedDB/large-number-of-inserts.html: Added.
* IndexedDB/objectstore-cursor.html: Added.

* resources/runner.js: Add "track responsiveness" functionality to PerfTestRunner.

2016-12-06 Filip Pizlo <fpizlo@apple.com>

Concurrent GC should be stable enough to land enabled
@@ -4,12 +4,14 @@
<script src="../resources/runner.js"></script>
<script>

var iterationCount = 11;
var iterationCount = 20;
var numberDeleted = 0;

// Delete all databases for the test ahead of time.
for (var i = 0; i < iterationCount; ++i) {
indexedDB.deleteDatabase("index-multientry-DB-" + i).onsuccess = function() {
var databaseNamePrefix = "index-multientry-DB-";
for (var i = 0; i < iterationCount + 1; ++i) {
req = indexedDB.deleteDatabase(databaseNamePrefix + i);
req.onsuccess = function() {
if (++numberDeleted == iterationCount)
startIteration();
}
@@ -44,14 +46,14 @@
}

var object = { test: 'yo', indexKeys: [] };
for (var i = 0; i < 1000; i++)
for (var i = 0; i < 5000; i++)
object.indexKeys.push('index_no_' + i);

function *runIteration()
{
var startTime = PerfTestRunner.now();

var openRequest = indexedDB.open("index-multientry-DB-" + currentIteration);
var openRequest = indexedDB.open(databaseNamePrefix + currentIteration);
openRequest.onupgradeneeded = function(event) {
db = event.target.result;
db.createObjectStore('store').createIndex('index', 'indexKeys', { multiEntry: true });
@@ -0,0 +1,83 @@
<!DOCTYPE html>
<html>
<body>
<script src="../resources/runner.js"></script>
<script>

var iterationCount = 20;
var numberDeleted = 0;

// Delete all databases for the test ahead of time.
var databasePrefix = "large-number-of-inserts-responsiveness-DB-";
for (var i = 0; i < iterationCount + 1; ++i) {
indexedDB.deleteDatabase(databasePrefix + i).onsuccess = function() {
if (++numberDeleted == iterationCount)
startIteration();
}
}

var testGenerator = null;
var db = null;
var currentIteration = 0;

PerfTestRunner.prepareToMeasureValuesAsync({
customIterationCount: iterationCount,
unit: 'ms',
done: function () {
db = null;
largestDelay = 0;
testGenerator = null;
PerfTestRunner.gc();
++currentIteration;
}
});

function startIteration()
{
testGenerator = runIteration();
nextStep();
}

function nextStep()
{
testGenerator.next();
}

var numberOfObjects = 50000;
var objectsToInsert = new Array(numberOfObjects);
for (var i = 0; i < numberOfObjects; ++i) {
objectsToInsert[i] = { data: Math.random() };
objectsToInsert[i].id = 'object_' + i;
}

function *runIteration()
{
var openRequest = indexedDB.open(databasePrefix + currentIteration);
openRequest.onupgradeneeded = function(event) {
db = event.target.result;
db.createObjectStore('objects', {keyPath: 'id'});
}
openRequest.onsuccess = nextStep;

yield;

var objectStore = db.transaction('objects', 'readwrite').objectStore('objects');
objectStore.transaction.oncomplete = nextStep;
for (var i = 0; i < numberOfObjects; ++i)
objectStore.put(objectsToInsert[i]);

PerfTestRunner.startCheckingResponsiveness();

yield;

PerfTestRunner.stopCheckingResponsiveness();

if (!PerfTestRunner.measureValueAsync(PerfTestRunner.longestResponsivenessDelay()))
return;

setTimeout(startIteration, 0);
}

</script>
</body>
</html>
@@ -0,0 +1,80 @@
<!DOCTYPE html>
<html>
<body>
<script src="../resources/runner.js"></script>
<script>

var iterationCount = 20;
var numberDeleted = 0;

// Delete all databases for the test ahead of time.
var databasePrefix = "large-number-of-inserts-DB-";
for (var i = 0; i < iterationCount + 1; ++i) {
indexedDB.deleteDatabase(databasePrefix + i).onsuccess = function() {
if (++numberDeleted == iterationCount)
startIteration();
}
}

var testGenerator = null;
var db = null;
var currentIteration = 0;

PerfTestRunner.prepareToMeasureValuesAsync({
customIterationCount: iterationCount,
unit: 'ms',
done: function () {
db = null;
testGenerator = null;
PerfTestRunner.gc();
++currentIteration;
}
});

function startIteration()
{
testGenerator = runIteration();
nextStep();
}

function nextStep()
{
testGenerator.next();
}

var numberOfObjects = 100000;
var objectsToInsert = new Array(numberOfObjects);
for (var i = 0; i < numberOfObjects; ++i) {
objectsToInsert[i] = { data: Math.random() };
objectsToInsert[i].id = 'object_' + i;
}

function *runIteration()
{
var openRequest = indexedDB.open(databasePrefix + currentIteration);
openRequest.onupgradeneeded = function(event) {
db = event.target.result;
db.createObjectStore('objects', {keyPath: 'id'});
}
openRequest.onsuccess = nextStep;

yield;

var startTime = PerfTestRunner.now();

var objectStore = db.transaction('objects', 'readwrite').objectStore('objects');
objectStore.transaction.oncomplete = nextStep;
for (var i = 0; i < numberOfObjects; ++i)
objectStore.put(objectsToInsert[i]);

yield;

if (!PerfTestRunner.measureValueAsync(PerfTestRunner.now() - startTime))
return;

setTimeout(startIteration, 0);
}

</script>
</body>
</html>
@@ -0,0 +1,82 @@
<!DOCTYPE html>
<html>
<body>
<script src="../resources/runner.js"></script>
<script>

var iterationCount = 20;
var numberDeleted = 0;
// Delete all databases for the test ahead of time.
var databaseName = "objectstore-cursor-DB";
indexedDB.deleteDatabase(databaseName).onsuccess = function() {
startIteration();
}

var testGenerator = null;
var db = null;
var currentIteration = 0;

PerfTestRunner.prepareToMeasureValuesAsync({
customIterationCount: iterationCount,
unit: 'ms',
done: function () {
db = null;
testGenerator = null;
PerfTestRunner.gc();
++currentIteration;
}
});

function startIteration()
{
testGenerator = runIteration();
nextStep();
}

function nextStep()
{
testGenerator.next();
}

function *runIteration()
{
var openRequest = indexedDB.open(databaseName);
openRequest.onupgradeneeded = function(event) {
db = event.target.result;
var objectStore = db.createObjectStore('store');
for (var i = 0; i < 50000; ++i) {
var suffix = ("0000000" + i).slice(-7);
objectStore.put("bar_value_" + suffix, "foo_key_" + suffix);
}
}
openRequest.onsuccess = nextStep;

yield;

var startTime = PerfTestRunner.now();
var cursorRequest = db.transaction('store').objectStore('store').openCursor();
var cursorIteration = 0;
cursorRequest.onsuccess = function(event) {
var cursor = event.target.result;
if (cursor) {
var suffix = ("0000000" + cursorIteration).slice(-7);
if (cursor.key != "foo_key_" + suffix)
alert("Incorrect value retrieved: " + cursor.key);
if (cursor.value != "bar_value_" + suffix)
alert("Incorrect value retrieved: " + cursor.key);
++cursorIteration;
cursor.continue();
} else
nextStep();
};

yield;

if (!PerfTestRunner.measureValueAsync(PerfTestRunner.now() - startTime))
return;

setTimeout(startIteration, 0);
}
</script>
</body>
</html>
@@ -15,6 +15,9 @@ if (window.testRunner) {
var jsHeapResults;
var mallocHeapResults;
var iterationCount = undefined;
var lastResponsivenessTimestamp = 0;
var _longestResponsivenessDelay = 0;
var continueCheckingResponsiveness = false;

var PerfTestRunner = {};

@@ -323,6 +326,32 @@ if (window.testRunner) {
return PerfTestRunner.now() - startTime;
}

PerfTestRunner.startCheckingResponsiveness = function() {
lastResponsivenessTimestamp = PerfTestRunner.now();
_longestResponsivenessDelay = 0;
continueCheckingResponsiveness = true;

var timeoutFunction = function() {
var now = PerfTestRunner.now();
var delta = now - lastResponsivenessTimestamp;
if (delta > _longestResponsivenessDelay)
_longestResponsivenessDelay = delta;

lastResponsivenessTimestamp = now;
if (continueCheckingResponsiveness)
setTimeout(timeoutFunction, 0);
}

timeoutFunction();
}

PerfTestRunner.stopCheckingResponsiveness = function() {
continueCheckingResponsiveness = false;
}

PerfTestRunner.longestResponsivenessDelay = function() {
return _longestResponsivenessDelay;
}

PerfTestRunner.measurePageLoadTime = function(test) {
test.run = function() {

0 comments on commit d38a43a

Please sign in to comment.