diff --git a/src/runtime/app.ts b/src/runtime/app.ts index 9256b5084..da4b0e0c6 100644 --- a/src/runtime/app.ts +++ b/src/runtime/app.ts @@ -1,6 +1,5 @@ import type { Collections, PageCollections, CollectionQueryBuilder, SurroundOptions, SQLOperator, QueryGroupFunction } from '@nuxt/content' import { collectionQueryBuilder } from './internal/query' -import { measurePerformance } from './internal/performance' import { generateNavigationTree } from './internal/navigation' import { generateItemSurround } from './internal/surround' import { generateSearchSections } from './internal/search' @@ -40,16 +39,10 @@ async function executeContentQuery(collection: T, sql: string) { - const perf = measurePerformance() - const rows = await import('./internal/database.client') .then(m => m.loadDatabaseAdapter(collection)) .then(db => db.all(sql)) - perf.tick('Execute Query') - - console.log(perf.end('Run with Compressed Dump')) - return rows as Result[] } diff --git a/src/runtime/internal/database.client.ts b/src/runtime/internal/database.client.ts index 927292529..5796d7eb3 100644 --- a/src/runtime/internal/database.client.ts +++ b/src/runtime/internal/database.client.ts @@ -1,6 +1,5 @@ import type { Database } from '@sqlite.org/sqlite-wasm' import type { DatabaseAdapter, DatabaseBindParams } from '@nuxt/content' -import { measurePerformance } from './performance' import { decompressSQLDump } from './dump' import { parseJsonFields } from './collection' import { fetchDatabase } from './api' @@ -36,12 +35,9 @@ export function loadDatabaseAdapter(collection: T): DatabaseAdapter { } async function loadAdapter(collection: T) { - const perf = measurePerformance() if (!db) { const sqlite3InitModule = await import('@sqlite.org/sqlite-wasm').then(m => m.default) const sqlite3 = await sqlite3InitModule() - perf.tick('Import SQLite Module') - db = new sqlite3.oo1.DB() } @@ -75,10 +71,8 @@ async function loadAdapter(collection: T) { } } - perf.tick('Get Local Cache') if (!compressedDump) { compressedDump = await fetchDatabase(undefined, String(collection)) - perf.tick('Download Database') if (!import.meta.dev) { try { window.localStorage.setItem(`content_${checksumId}`, checksums[String(collection)]) @@ -87,12 +81,10 @@ async function loadAdapter(collection: T) { catch (error) { console.error('Database integrity check failed, rebuilding database', error) } - perf.tick('Store Database') } } const dump = await decompressSQLDump(compressedDump!) - perf.tick('Decompress Database') await db.exec({ sql: `DROP TABLE IF EXISTS ${tables[String(collection)]}` }) if (checksumState === 'mismatch') { @@ -107,10 +99,7 @@ async function loadAdapter(collection: T) { console.error('Error executing command', error) } } - perf.tick('Restore Dump') } - perf.end('Database Loaded') - return db } diff --git a/src/runtime/internal/performance.ts b/src/runtime/internal/performance.ts deleted file mode 100644 index b38388053..000000000 --- a/src/runtime/internal/performance.ts +++ /dev/null @@ -1,21 +0,0 @@ -export function measurePerformance() { - const times = [ - { name: 'start', time: performance.now() }, - ] - - return { - tick(name: string) { - times.push({ name, time: performance.now() }) - }, - end(jobName: string) { - const timesString = times.reduce((acc, time, index) => { - if (index > 0) { - acc.push(`-- ${time.name}: ${(time.time - times[index - 1].time).toPrecision(4)}ms\n`) - } - return acc - }, [] as string[]) - - return `${jobName}: ${(times[times.length - 1].time - times[0].time).toPrecision(4)}ms\n${timesString.join('')}` - }, - } -}