Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(614)

Unified Diff: chrome/test/data/indexeddb/perf_test.js

Issue 10575043: Initial checkin of a perf test suite for Indexed Database. This just has a (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove junk from other branch. Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/indexeddb/perf_test.js
diff --git a/chrome/test/data/indexeddb/perf_test.js b/chrome/test/data/indexeddb/perf_test.js
new file mode 100644
index 0000000000000000000000000000000000000000..4fbcfecd5d68cd2118c5e2e17bd8dd4643789763
--- /dev/null
+++ b/chrome/test/data/indexeddb/perf_test.js
@@ -0,0 +1,72 @@
+var overallTestStartTime = Date.now();
+
+function testCreateKeysInStores(
+ numKeys, numStores, payloadLength, onTestComplete) {
+ var testName = "testCreateKeysInStores_" + numKeys + "_" + numStores + "_" +
+ payloadLength;
+ assert(numKeys >= 0);
+ assert(numStores >= 1);
+ var objectStoreNames = [];
+ for (var i=0; i < numStores; ++i) {
+ objectStoreNames.push("store " + i);
+ }
+ var value = stringOfLength(payloadLength);
+ var start;
+
+ function onCreated(db) {
+ automation.setStatus("Constructing transaction.");
+ start = Date.now(); // Ignore the setup time for this test.
+ var transaction = getTransaction(db, objectStoreNames, "readwrite",
+ function() { onTransactionComplete(db); });
+ for (var i in objectStoreNames) {
+ var os = transaction.objectStore(objectStoreNames[i]);
+ assert(os);
+ for (var j = 0; j < numKeys; ++j) {
+ os.put("key " + j, value);
jsbell 2012/06/21 00:04:16 This is measuring three distinct things: * Time ta
+ }
+ }
+ }
+ function onTransactionComplete(db) {
+ var duration = Date.now() - start;
+ // Ignore the cleanup time for this test.
+ automation.addResult(testName, duration);
+ automation.setStatus("Deleting.");
+ deleteDatabase(db, onDeleted);
+ }
+ function onDeleted() {
+ automation.setStatus("Deleted.");
+ onTestComplete();
+ }
+ automation.setStatus("Creating.");
+ createDatabase(testName, objectStoreNames, onCreated, onError);
+}
+
+var tests = [
+ [testCreateKeysInStores, 1, 1, 1],
+ [testCreateKeysInStores, 100, 1, 1],
+ [testCreateKeysInStores, 1, 100, 1],
+ [testCreateKeysInStores, 100, 1, 100000]
+];
+
+var currentTest = 0;
+
+function runNextTest() {
+ if (currentTest < tests.length) {
+ var test = tests[currentTest++].slice();
+ var f = test.shift();
+ test.push(runNextTest);
+ f.apply(null, test);
+ } else {
+ onAllTestsComplete();
+ }
+}
+
+function onAllTestsComplete() {
+ var overallDuration = Date.now() - overallTestStartTime;
+ automation.addResult("OverallTestDuration", overallDuration);
+ automation.setDone();
+}
+
+function test() {
+ runNextTest();
+}

Powered by Google App Engine
This is Rietveld 408576698