Skip to content
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
4 changes: 4 additions & 0 deletions .github/workflows/benchmark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.ref }}

permissions:
contents: write
pull-requests: write

jobs:
benchmark:
name: Run Benchmarks
Expand Down
72 changes: 67 additions & 5 deletions benchmark/put-sync.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { benchmark, generateRandomKeys, generateSequentialKeys, randomString } f
describe('putSync()', () => {
const SMALL_DATASET = 100;

describe('random keys - small key size (100 records)', () => {
describe('random keys - insert - small key size (100 records)', () => {
benchmark('rocksdb', {
setup(ctx) {
ctx.data = generateRandomKeys(SMALL_DATASET);
Expand All @@ -28,7 +28,35 @@ describe('putSync()', () => {
});
});

describe('random keys - max 1978 lmdb key size (100 records)', () => {
describe('random keys - update - small key size (100 records)', () => {
function setup(ctx) {
const data = generateRandomKeys(SMALL_DATASET);
for (const key of data) {
ctx.db.putSync(key, 'test-value');
}
ctx.data = data.sort(() => Math.random() - 0.5);
}

benchmark('rocksdb', {
setup,
bench({ data, db }) {
for (const key of data) {
db.putSync(key, 'test-value-updated');
}
}
});

benchmark('lmdb', {
setup,
bench({ data, db }) {
for (const key of data) {
db.putSync(key, 'test-value-updated');
}
}
});
});

describe('random keys - insert - max 1978 lmdb key size (100 records)', () => {
benchmark('rocksdb', {
setup(ctx) {
ctx.data = generateRandomKeys(SMALL_DATASET, 1978);
Expand All @@ -52,25 +80,59 @@ describe('putSync()', () => {
});
});

describe('sequential keys (100 records)', () => {
describe('random keys - update - max 1978 lmdb key size (100 records)', () => {
function setup(ctx) {
const data = generateRandomKeys(SMALL_DATASET, 1978);
for (const key of data) {
ctx.db.putSync(key, 'test-value');
}
ctx.data = data.sort(() => Math.random() - 0.5);
}

benchmark('rocksdb', {
setup,
bench({ data, db }) {
for (const key of data) {
db.putSync(key, 'test-value-updated');
}
}
});

benchmark('lmdb', {
setup,
bench({ data, db }) {
for (const key of data) {
db.putSync(key, 'test-value-updated');
}
}
});
});

describe('sequential keys - insert (100 records)', () => {
benchmark('rocksdb', {
setup(ctx) {
ctx.data = generateSequentialKeys(SMALL_DATASET);
for (const key of ctx.data) {
ctx.db.putSync(key, 'test-value');
}
},
bench({ data, db }) {
for (const key of data) {
db.putSync(key, 'test-value');
db.putSync(key, 'test-value-updated');
}
}
});

benchmark('lmdb', {
setup(ctx) {
ctx.data = generateSequentialKeys(SMALL_DATASET);
for (const key of ctx.data) {
ctx.db.putSync(key, 'test-value');
}
},
bench({ data, db }) {
for (const key of data) {
db.putSync(key, 'test-value');
db.putSync(key, 'test-value-updated');
}
}
});
Expand Down
Loading