Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ src/storage/base-storage-manager.js
src/storage/dexieDB-manager.js
src/storage/indexedDB-manager.js
src/storage/storage-factory.js
src/storage/storage-type.js
src/utils/nanoid.js
src/workload-test.mjs
styles/app.constructable.js
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import IndexedDBManager from "./indexedDB-manager.js";
import DexieDBManager from "./dexieDB-manager.js";
import { getStorageType } from "./storage-type.js";

/**
* Factory function that returns the appropriate storage manager based on URL search parameters
* @returns {IndexedDBManager|DexieDBManager} The storage manager instance
*/
export function createStorageManager() {
const params = new URLSearchParams(window.location.search);
let storageType = params.get("storageType");
if (storageType && storageType !== "vanilla" && storageType !== "dexie")
throw new Error(`Invalid storage type specified in URL parameter: ${storageType}`);

storageType = storageType || "vanilla";
const storageType = getStorageType();

if (storageType === "dexie") {
console.log("Using Dexie.js storage manager");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Import-free on purpose: importing storage-factory.js from workload-test.mjs
* would close a cycle through the storage managers.
* @returns {"vanilla"|"dexie"} The storage type
*/
export function getStorageType() {
const params = new URLSearchParams(window.location.search);
const storageType = params.get("storageType");
if (storageType && storageType !== "vanilla" && storageType !== "dexie")
throw new Error(`Invalid storage type specified in URL parameter: ${storageType}`);

return storageType || "vanilla";
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { BenchmarkStep, BenchmarkSuite } from "./speedometer-utils/benchmark.mjs";
import { getTodoText, defaultLanguage } from "./speedometer-utils/translations.mjs";
import { numberOfItemsToAdd } from "./speedometer-utils/todomvc-utils.mjs";
import { getStorageType } from "./storage/storage-type.js";

export const appName = "todomvc-indexeddb";
export const appVersion = "1.0.0";
Expand Down Expand Up @@ -28,8 +29,10 @@ function waitForPreviousPageLoaded() {
});
}

const suiteName = getStorageType() === "dexie" ? "TodoMVC-WebComponents-DexieJS" : "TodoMVC-WebComponents-IndexedDB";

const suites = {
default: new BenchmarkSuite("indexeddb", [
default: new BenchmarkSuite(suiteName, [
new BenchmarkStep(`Adding${numberOfItemsToAdd}Items`, async () => {
const input = document.querySelector("todo-app").shadowRoot.querySelector("todo-topbar").shadowRoot.querySelector(".new-todo-input");
for (let i = 0; i < numberOfItemsToAdd; i++) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import IndexedDBManager from "./indexedDB-manager.js";
import DexieDBManager from "./dexieDB-manager.js";
import { getStorageType } from "./storage-type.js";

/**
* Factory function that returns the appropriate storage manager based on URL search parameters
* @returns {IndexedDBManager|DexieDBManager} The storage manager instance
*/
export function createStorageManager() {
const params = new URLSearchParams(window.location.search);
let storageType = params.get("storageType");
if (storageType && storageType !== "vanilla" && storageType !== "dexie")
throw new Error(`Invalid storage type specified in URL parameter: ${storageType}`);

storageType = storageType || "vanilla";
const storageType = getStorageType();

if (storageType === "dexie") {
console.log("Using Dexie.js storage manager");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Import-free on purpose: importing storage-factory.js from workload-test.mjs
* would close a cycle through the storage managers.
* @returns {"vanilla"|"dexie"} The storage type
*/
export function getStorageType() {
const params = new URLSearchParams(window.location.search);
const storageType = params.get("storageType");
if (storageType && storageType !== "vanilla" && storageType !== "dexie")
throw new Error(`Invalid storage type specified in URL parameter: ${storageType}`);

return storageType || "vanilla";
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { BenchmarkStep, BenchmarkSuite } from "./speedometer-utils/benchmark.mjs";
import { getTodoText, defaultLanguage } from "/node_modules/speedometer-utils/translations.mjs";
import { numberOfItemsToAdd } from "/node_modules/speedometer-utils/todomvc-utils.mjs";
import { getStorageType } from "./storage/storage-type.js";

export const appName = "todomvc-indexeddb";
export const appVersion = "1.0.0";
Expand Down Expand Up @@ -28,8 +29,10 @@ function waitForPreviousPageLoaded() {
});
}

const suiteName = getStorageType() === "dexie" ? "TodoMVC-WebComponents-DexieJS" : "TodoMVC-WebComponents-IndexedDB";

const suites = {
default: new BenchmarkSuite("indexeddb", [
default: new BenchmarkSuite(suiteName, [
new BenchmarkStep(`Adding${numberOfItemsToAdd}Items`, async () => {
const input = document.querySelector("todo-app").shadowRoot.querySelector("todo-topbar").shadowRoot.querySelector(".new-todo-input");
for (let i = 0; i < numberOfItemsToAdd; i++) {
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion suites/newssite/news-next/src/workload-test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { BenchmarkStep, BenchmarkSuite } from "speedometer-utils/benchmark.mjs";
import { forceLayout, getElement } from "speedometer-utils/helpers.mjs";

const suites = {
default: new BenchmarkSuite("default", [
default: new BenchmarkSuite("NewsSite-PostMessage", [
new BenchmarkStep("Navigate-to-US-page", () => {
for (let i = 0; i < 25; i++) {
getElement("#navbar-dropdown-toggle").click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const appName = "todomvc-postmessage";
export const appVersion = "1.0.0";

const suites = {
default: new BenchmarkSuite("default", [
default: new BenchmarkSuite("TodoMVC-WebComponents-PostMessage", [
new BenchmarkStep("Adding-items", () => {
const input = getElement(".new-todo-input", ["todo-app", "todo-topbar"]);
for (let i = 0; i < numberOfItemsToAdd; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const appName = "todomvc-postmessage";
export const appVersion = "1.0.0";

const suites = {
default: new BenchmarkSuite("default", [
default: new BenchmarkSuite("TodoMVC-WebComponents-PostMessage", [
new BenchmarkStep("Adding-items", () => {
const input = getElement(".new-todo-input", ["todo-app", "todo-topbar"]);
for (let i = 0; i < numberOfItemsToAdd; i++) {
Expand Down