Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds better benchmarks #809

Merged
merged 1 commit into from
Oct 4, 2024
Merged
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
52 changes: 52 additions & 0 deletions benchmarks/common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import * as orama_2_1_1 from 'npm:@orama/[email protected]'
import * as orama_3_0_0_rc_2 from 'npm:@orama/[email protected]'
import * as orama_latest from '../packages/orama/dist/deno/index.js'
import dataset from './dataset.json' with { type: 'json' }

const schema = {
title: 'string',
description: 'string',
rating: 'number',
genres: 'enum[]'
}

async function getV2_1_1DB() {
const db = await orama_2_1_1.create({ schema })

for (const doc of dataset) {
await orama_2_1_1.insert(db, doc)
}

return db
}

function getV3_0_0_rc_2DB() {
const db = orama_3_0_0_rc_2.create({ schema })

for (const doc of dataset) {
orama_3_0_0_rc_2.insert(db, doc)
}

return db
}

function getLatestDB() {
const db = orama_latest.create({ schema })

for (const doc of dataset) {
orama_latest.insert(db, doc)
}

return db
}

export {
orama_2_1_1,
orama_3_0_0_rc_2,
orama_latest,
schema,
dataset,
getV2_1_1DB,
getV3_0_0_rc_2DB,
getLatestDB
}
14,231 changes: 14,231 additions & 0 deletions benchmarks/dataset.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions benchmarks/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "@orama/benchmarks"
}
15 changes: 15 additions & 0 deletions benchmarks/deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions benchmarks/insert_bench.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { orama_2_1_1, orama_3_0_0_rc_2, orama_latest, schema, dataset } from './common.js'

Deno.bench('v2.1.1 insert', async () => {
const db = await orama_2_1_1.create({ schema })

for (const doc of dataset) {
await orama_2_1_1.insert(db, doc)
}
})

Deno.bench('v3.0.0-rc2 insert', () => {
const db = orama_3_0_0_rc_2.create({ schema })

for (const doc of dataset) {
orama_3_0_0_rc_2.insert(db, doc)
}
})

Deno.bench('latest insert', () => {
const db = orama_latest.create({ schema })

for (const doc of dataset) {
orama_latest.insert(db, doc)
}
})
47 changes: 47 additions & 0 deletions benchmarks/search_filters_bench.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { orama_2_1_1, orama_3_0_0_rc_2, orama_latest, getV2_1_1DB, getV3_0_0_rc_2DB, getLatestDB } from './common.js'

const v2_1_1DB = await getV2_1_1DB()
const v3_0_0_rc_2DB = getV3_0_0_rc_2DB()
const latestDB = getLatestDB()

Deno.bench('v2.1.1 search (with filters)', async () => {
await orama_2_1_1.search(v2_1_1DB, {
term: 'AI companions',
where: {
rating: {
gte: 3
},
genres: {
containsAll: ['RPG']
}
}
})
})

Deno.bench('v3.0.0-rc2 search (with filters)', () => {
orama_3_0_0_rc_2.search(v3_0_0_rc_2DB, {
term: 'AI companions',
where: {
rating: {
gte: 3
},
genres: {
containsAll: ['RPG']
}
}
})
})

Deno.bench('latest search (with filters)', () => {
orama_latest.search(latestDB, {
term: 'AI companions',
where: {
rating: {
gte: 3
},
genres: {
containsAll: ['RPG']
}
}
})
})
23 changes: 23 additions & 0 deletions benchmarks/search_plain_bench.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { orama_2_1_1, orama_3_0_0_rc_2, orama_latest, getV2_1_1DB, getV3_0_0_rc_2DB, getLatestDB } from './common.js'

const v2_1_1DB = await getV2_1_1DB()
const v3_0_0_rc_2DB = getV3_0_0_rc_2DB()
const latestDB = getLatestDB()

Deno.bench('v2.1.1 search', async () => {
await orama_2_1_1.search(v2_1_1DB, {
term: 'super mario'
})
})

Deno.bench('v3.0.0-rc2 search', () => {
orama_3_0_0_rc_2.search(v3_0_0_rc_2DB, {
term: 'super mario'
})
})

Deno.bench('latest search', () => {
orama_latest.search(latestDB, {
term: 'super mario'
})
})
1 change: 0 additions & 1 deletion packages/benchmarks/.gitignore

This file was deleted.

15 changes: 0 additions & 15 deletions packages/benchmarks/package.json

This file was deleted.

180 changes: 0 additions & 180 deletions packages/benchmarks/src/combination.bench.js

This file was deleted.

Loading
Loading