Skip to content

Add JMH Benchmarking Suite for Performance Comparison #67

@yaziza

Description

@yaziza

Problem

No systematic performance benchmarking infrastructure exists. Current ad-hoc performance tests against BouncyCastle in e.g. BotanMessageDigestTest.java and BotanMacTest.java should be removed and replaced with proper JMH benchmarks.

Goal

Implement JMH benchmarking to measure Botanj performance against other Java crypto providers (SunJCE, BouncyCastle, Corretto) and track performance over time.

Scope

Cryptographic Operations

  • Message Digests: SHA-256, SHA-512, SHA3-256, BLAKE2b
  • MACs: HMAC-SHA256, HMAC-SHA512, CMAC-AES, Poly1305
  • Block Ciphers: AES-CBC, AES-CTR, AES-GCM
  • Stream Ciphers: ChaCha20, Salsa20

Benchmark Types

  • Throughput at various data sizes (1KB, 16KB, 1MB)
  • Latency measurements

Providers to Compare

  • SunJCE (baseline)
  • BouncyCastle (pure Java, already a dependency)
  • Corretto (Amazon provider)

Implementation

Tasks

  • Add JMH and Conscrypt dependencies to pom.xml
  • Create src/jmh/java/net/randombit/botan/benchmark/ directory
  • Remove existing performance tests from
  • Implement JMH benchmarks for MessageDigest algorithms
  • Implement JMH benchmarks for MAC algorithms
  • Implement JMH benchmarks for Cipher operations
  • Add benchmark execution profile to Maven
  • Document how to run benchmarks in BENCHMARKING.md
  • Optional: Add CI workflow for performance regression detection

Example Benchmark Output

Benchmark                          Mode  Cnt    Score    Error  Units
SHA256_1KB_Botanj                 thrpt   10  5234.5 ±  23.4  ops/s
SHA256_1KB_BouncyCastle           thrpt   10  3456.8 ±  12.3  ops/s
SHA256_1KB_SunJCE                 thrpt   10  4123.5 ±  18.9  ops/s

References

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions