Benchmark suite comparing Java PDF generation libraries using JMH (Java Microbenchmark Harness).
| Library | Artifact | Version |
|---|---|---|
| PDFixa | io.offixa:pdfixa |
— |
| Apache PDFBox | org.apache.pdfbox:pdfbox |
3.0.3 |
| iText 7 | com.itextpdf:layout |
7.2.6 |
| OpenPDF | com.github.librepdf:openpdf |
2.0.3 |
| Scenario | Class | Description |
|---|---|---|
| Invoice generation | InvoiceScenario |
Single-page invoice with 10 line items, totals, header |
| Report generation | ReportScenario |
Multi-section structured report document |
| Large document | LargeDocumentScenario |
High page-count document for throughput measurement |
Each scenario exposes one generation method per library, all returning byte[].
src/main/java/io/offixa/benchmark/
├── scenarios/
│ ├── InvoiceScenario.java
│ ├── ReportScenario.java
│ └── LargeDocumentScenario.java
├── pdfixa/
│ └── PdfixaBenchmark.java
├── itext/
│ └── ITextBenchmark.java
├── pdfbox/
│ └── PdfBoxBenchmark.java
├── openpdf/
│ └── OpenPdfBenchmark.java
├── DocumentBenchmark.java
└── DeterminismTest.java
- Java 17+
- Maven 3.8+
Build the project and produce a self-contained executable JAR:
mvn clean installRun all benchmarks:
java -jar target/benchmarks.jarRun a specific benchmark by name:
java -jar target/benchmarks.jar benchmarkPdfBoxInvoiceList all available benchmarks without running them:
java -jar target/benchmarks.jar -lCommon options to control benchmark execution:
| Flag | Description | Example |
|---|---|---|
-f |
Number of forks | -f 2 |
-wi |
Warmup iterations | -wi 5 |
-i |
Measurement iterations | -i 10 |
-t |
Number of threads | -t 1 |
-bm |
Benchmark mode | -bm avgt |
-tu |
Time unit for output | -tu ms |
Example with explicit parameters:
java -jar target/benchmarks.jar -f 2 -wi 5 -i 10 -bm avgt -tu msAll benchmarks are configured with:
- Mode:
AverageTime— reports the average time per operation - Output unit: milliseconds
- Scope:
Benchmark— one shared state instance per benchmark run
Benchmarks are executed via JMH which handles JVM warmup, forking, and statistical output to produce reproducible results. Each benchmark run is isolated in a forked JVM to avoid cross-contamination between measurements.
The DeterminismTest class generates each document twice and compares SHA-256 hashes of the outputs to verify that a library produces byte-identical output across calls with the same input:
mvn -q "-Dexec.mainClass=io.offixa.benchmark.DeterminismTest" \
org.codehaus.mojo:exec-maven-plugin:3.5.0:javaSample output:
PDFixa deterministic: true
PDFBox deterministic: false
IText deterministic: false
OpenPDF deterministic: false
Non-deterministic output is common in PDF libraries due to embedded timestamps, unique object identifiers, or internal state that varies between runs.
See individual library licenses. This benchmark harness itself carries no additional restrictions.