Skip to content

Commit

Permalink
chore: remove performance measurement logs
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed Jan 7, 2025
1 parent 53bf75d commit 6f7b4df
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 39 deletions.
7 changes: 0 additions & 7 deletions src/runtime/app.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -40,16 +39,10 @@ async function executeContentQuery<T extends keyof Collections, Result = Collect
}

async function queryContentSqlClientWasm<T extends keyof Collections, Result = Collections[T]>(collection: T, sql: string) {
const perf = measurePerformance()

const rows = await import('./internal/database.client')
.then(m => m.loadDatabaseAdapter(collection))
.then(db => db.all<Result>(sql))

perf.tick('Execute Query')

console.log(perf.end('Run with Compressed Dump'))

return rows as Result[]
}

Expand Down
11 changes: 0 additions & 11 deletions src/runtime/internal/database.client.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -36,12 +35,9 @@ export function loadDatabaseAdapter<T>(collection: T): DatabaseAdapter {
}

async function loadAdapter<T>(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()
}

Expand Down Expand Up @@ -75,10 +71,8 @@ async function loadAdapter<T>(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)])
Expand All @@ -87,12 +81,10 @@ async function loadAdapter<T>(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') {
Expand All @@ -107,10 +99,7 @@ async function loadAdapter<T>(collection: T) {
console.error('Error executing command', error)
}
}
perf.tick('Restore Dump')
}

perf.end('Database Loaded')

return db
}
21 changes: 0 additions & 21 deletions src/runtime/internal/performance.ts

This file was deleted.

0 comments on commit 6f7b4df

Please sign in to comment.