Commit b4ce76bd authored by Numfor Mbiziwo-Tiapo's avatar Numfor Mbiziwo-Tiapo Committed by Commit Bot

Add IndexedDB put test

This adds a put test for indexedDB that inserts records into 2 different
object stores. Each record contains values that vary in size.

Change-Id: Iac672ea57ccca3ed628ffee2368b8174453526df
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2240875Reviewed-by: default avatarOlivier Yiptong <oyiptong@chromium.org>
Reviewed-by: default avatarDaniel Murphy <dmurph@chromium.org>
Reviewed-by: default avatarChristian Biesinger <cbiesinger@chromium.org>
Commit-Queue: Daniel Murphy <dmurph@chromium.org>
Cr-Commit-Position: refs/heads/master@{#778381}
parent ac43cb85
<!doctype html>
<title>IndexedDB Put Test</title>
<script src="../resources/runner.js"></script>
<script src="resources/shared.js"></script>
<script>
deleteThenOpen('library',
(db) => {
const store1 = db.createObjectStore('books_with_index', {keyPath: 'isbn'})
store1.createIndex('by_title', 'title')
db.createObjectStore('books', {keyPath: 'isbn'})
},
() => {
const test = {
description: 'Benchmark modeling the IndexedDB activity of putting a'
+ 'record into an object store',
unit: 'ms',
iterationCount: 20,
tracingCategories: 'IndexedDB',
traceEventsToMeasure: ['IDBObjectStore::put'],
path: 'resources/idb-put-runner.html'
}
PerfTestRunner.measurePageLoadTimeAfterDoneMessage(test);
}
);
</script>
<!doctype html>
<title>IDB Put Runner</title>
<script src="resources/shared.js"></script>
<script>
const contents = [];
const blobs = [];
function chooseContent(i) {
return contents[i % 3];
}
function chooseBlob(i) {
return blobs[i % 4];
}
function chooseTitle(i) {
let smallTitle = ((i % 20).toString()).repeat(100);
let largeTitle = ((i % 20).toString()).repeat(2000);
let titles = [smallTitle, largeTitle]
return titles[i % 2]
}
function initHelperValues() {
contents.push(new Uint8Array(100));
contents.push(new Uint8Array(50000));
contents.push(new Uint8Array(150000));
blobs.push(null)
blobs.push(new Uint8Array(1000));
blobs.push(new Uint8Array(200000));
blobs.push(new Uint8Array(500000));
}
function start() {
const openRequest = window.indexedDB.open('library');
openRequest.onsuccess = function() {
const db = openRequest.result;
const txn = db.transaction(['books_with_index','books'],'readwrite');
const store1 = txn.objectStore('books_with_index');
const store2 = txn.objectStore('books');
logToDocumentBody('Starting Benchmark IDB put');
for(let i = 0; i < 100; i++) {
logToDocumentBody('Putting books into the library');
let content = chooseContent(i);
let blob = chooseBlob(i);
let title = chooseTitle(i);
store1.put({isbn: i, content: content, blob: blob,
title: title, author: 'Fred',});
store2.put({isbn: i, content: content, blob: blob, title: title,
author: 'Fred'});
}
logToDocumentBody('Finished Benchmark IDB put');
txn.oncomplete = () => {
reportDone();
}
}
}
initHelperValues()
start();
</script>
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment