Skip to content

Add reusable performance test suite for adapter benchmarking#406

Merged
pubkey merged 2 commits intomasterfrom
copilot/add-performance-tests-for-adapters
Apr 15, 2026
Merged

Add reusable performance test suite for adapter benchmarking#406
pubkey merged 2 commits intomasterfrom
copilot/add-performance-tests-for-adapters

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 14, 2026

Adds an exported performanceTest() function so adapter authors can benchmark custom adapters against a standard set of operations. Includes a test running the suite against the Express adapter.

Changes

  • src/plugins/server/performance-test.ts — New module with performanceTest() that benchmarks 6 operations: bulk write, query, get-by-id, bulk delete, sequential single-doc writes, and replication pull. Returns structured PerformanceTestResult[] with timing and ops/sec.
  • src/plugins/server/index.ts — Re-exports performanceTest, PerformanceTestResult, PerformanceTestOptions
  • test/unit/performance.test.ts — Runs the suite against RxServerAdapterExpress, logs results, asserts sanity
  • test/unit.test.ts — Registers the new test file

Usage for custom adapters

import { performanceTest } from 'rxdb-server/plugins/server';

const results = await performanceTest({
    adapter: myCustomAdapter,
    createDatabase: () => createRxDatabase({ name: 'bench-' + randomToken(6), storage }),
    getPort: () => getAvailablePort(),
    batchSize: 50
});

for (const r of results) {
    console.log(`${r.name}: ${r.timeMs.toFixed(1)}ms (${r.opsPerSecond} ops/sec)`);
}

The PerformanceTestOptions interface takes an adapter, a database factory, a port provider, and an optional batchSize (default 30). Each test spins up its own server/collection and tears down after measurement.

@pubkey pubkey marked this pull request as ready for review April 15, 2026 07:13
@pubkey pubkey merged commit aacbd70 into master Apr 15, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants