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

Add perf test for IDB putAll

This adds a perf test for the current implementation of IDB putAll.
There is currently no trace for putAll but once a trace is added this
test will allow for putAll to be benchmarked.

Change-Id: If9ce6b07d727ded4e36fa190e6981d00636d2b6a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2283512Reviewed-by: default avatarChristian Biesinger <cbiesinger@chromium.org>
Reviewed-by: default avatarDaniel Murphy <dmurph@chromium.org>
Reviewed-by: default avatarOlivier Yiptong <oyiptong@chromium.org>
Commit-Queue: Daniel Murphy <dmurph@chromium.org>
Cr-Commit-Position: refs/heads/master@{#788648}
parent b8c6444f
<!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 using putAll',
unit: 'ms',
iterationCount: 20,
tracingCategories: 'IndexedDB',
traceEventsToMeasure: ['IDBObjectStore::putAll'],
path: 'resources/idb-put-all-runner.html'
}
PerfTestRunner.measurePageLoadTimeAfterDoneMessage(test);
}
);
</script>
<!doctype html>
<title>IDB Put Runner</title>
<script src="resources/shared.js"></script>
<script>
const contents = [];
const blobs = [];
const values = [];
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));
for(let i = 0; i < 100; i++) {
let content = chooseContent(i);
let blob = chooseBlob(i);
let title = chooseTitle(i);
values.push({isbn: i, content: content, blob: blob,
title: title, author: 'Fred'});
}
}
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 putAll');
store1.putAll(values);
store2.putAll(values);
logToDocumentBody('Finished Benchmark IDB putAll');
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