Skip to content

offixa/pdfixa-benchmark

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java PDF Library Benchmarks

Benchmark suite comparing Java PDF generation libraries using JMH (Java Microbenchmark Harness).

Libraries Tested

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

Benchmark Scenarios

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[].

Project Structure

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

Requirements

  • Java 17+
  • Maven 3.8+

Running Benchmarks

Build the project and produce a self-contained executable JAR:

mvn clean install

Run all benchmarks:

java -jar target/benchmarks.jar

Run a specific benchmark by name:

java -jar target/benchmarks.jar benchmarkPdfBoxInvoice

List all available benchmarks without running them:

java -jar target/benchmarks.jar -l

JMH Options

Common 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 ms

Benchmark Configuration

All 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.

Determinism Check

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:java

Sample 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.

License

See individual library licenses. This benchmark harness itself carries no additional restrictions.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages