Skip to content

Commit

Permalink
bookmarks: Add test-only function for creating lots of stashed tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
josh-berry committed Aug 6, 2023
1 parent 0ce76dc commit a970b4c
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/model/bookmarks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,44 @@ export class Model {
if (!index) return;
index.delete(bm);
}

/** Create a bunch of fake(-ish) tabs for benchmarking purposes. This is
* private because no actual code should call this, but we want it accessible
* at runtime. */
async createTabsForBenchmarks_testonly(options: {
name?: string;
folder_count: number;
folder_levels: number;
tabs_per_folder: number;
}): Promise<void> {
const bench_folder = await this.createStashFolder(
options.name ?? "Fake Tabs",
);

const populate_folder = async (
parent: Folder,
levels: number,
path: string,
) => {
if (levels > 0) {
for (let i = 0; i < options.folder_count; ++i) {
const f = await this.createStashFolder(undefined, parent.id);
await populate_folder(f, levels - 1, `${path}-${i}`);
}
} else {
for (let i = 0; i < options.tabs_per_folder; ++i) {
await this.create({
title: `Fake Tab #${i}`,
url: `http://example.com/#${path}-${i}`,
parentId: parent.id,
index: i,
});
}
}
};

await populate_folder(bench_folder, options.folder_levels, "root");
}
}

//
Expand Down

0 comments on commit a970b4c

Please sign in to comment.