Skip to content

Conversation

@lowhung
Copy link
Owner

@lowhung lowhung commented Dec 24, 2025

Closes #17

Summary

This PR adds comprehensive performance benchmarks to buswatch-sdk using Criterion.rs to measure and track performance of critical SDK operations.

Changes

  • ✅ Add criterion 0.5 as dev-dependency with html_reports feature
  • ✅ Create 4 benchmark suites covering all requirements from test: Add performance benchmarks with criterion #17:
    • record_operations: Measures record_read() and record_write() hot path latency
    • snapshot_collection: Measures collect() snapshot generation time with varying module/topic counts
    • concurrent_throughput: Measures concurrent increment throughput across multiple threads
    • serialization: Measures JSON serialization and deserialization performance
  • ✅ Add [[bench]] sections to Cargo.toml for each benchmark suite
  • ✅ Update README.md with benchmark documentation and usage examples
  • ✅ Update CHANGELOG.md with benchmark feature details

Benchmark Coverage

record_operations

  • Single operation latency for record_read and record_write
  • Varying message counts (1, 10, 100, 1000)
  • Mixed read/write operations
  • Multiple topics

snapshot_collection

  • Varying topic counts (1, 5, 10, 50, 100)
  • Varying module counts (1, 5, 10, 20, 50)
  • Realistic workload scenarios
  • Empty snapshots (baseline)

concurrent_throughput

  • Varying thread counts (1, 2, 4, 8, 16)
  • High contention (same topic) vs low contention (different topics)
  • Mixed concurrent operations
  • Concurrent collect() calls

serialization

  • Varying snapshot sizes (small, medium, large, xlarge)
  • Pretty-printed JSON
  • Deserialization
  • Round-trip serialization
  • Realistic application scenarios

Usage

# Run all benchmarks
cargo bench

# Run specific benchmark suite
cargo bench --bench record_operations
cargo bench --bench snapshot_collection
cargo bench --bench concurrent_throughput
cargo bench --bench serialization

Results are saved to target/criterion/ with HTML reports for detailed analysis.

Testing

  • ✅ All benchmarks compile successfully
  • ✅ All benchmarks run without errors (tested with --test flag)
  • ✅ All existing tests pass
  • ✅ Documentation builds correctly

Implements #17

- Add criterion 0.5 as dev-dependency with html_reports feature
- Create comprehensive benchmark suites:
  * record_operations: Measures record_read/record_write hot path latency
  * snapshot_collection: Measures collect() performance with varying scales
  * concurrent_throughput: Measures multi-threaded increment throughput
  * serialization: Measures JSON serialization/deserialization performance
- Add [[bench]] sections to Cargo.toml for each benchmark suite
- Update README.md with benchmark documentation and usage examples
- Update CHANGELOG.md with benchmark feature details

All benchmarks use criterion's statistical analysis and generate HTML
reports in target/criterion/ for detailed performance analysis.
@lowhung lowhung changed the title Add tracing integration for structured logging to buswatch-sdk Add performance benchmarks with criterion to buswatch-sdk Dec 24, 2025
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.

test: Add performance benchmarks with criterion

2 participants