Skip to content

chore: update benchmarks and add @cantoo/pdf-lib for comparison#49

Merged
Mythie merged 1 commit intomainfrom
chore/update-benchmarks
Mar 11, 2026
Merged

chore: update benchmarks and add @cantoo/pdf-lib for comparison#49
Mythie merged 1 commit intomainfrom
chore/update-benchmarks

Conversation

@Mythie
Copy link
Contributor

@Mythie Mythie commented Mar 11, 2026

No description provided.

@vercel
Copy link
Contributor

vercel bot commented Mar 11, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
core Ready Ready Preview, Comment Mar 11, 2026 2:27am

@github-actions
Copy link
Contributor

Benchmark Results

Comparison

Load PDF

Benchmark Mean p99 RME Samples
libpdf 2.50ms 4.08ms ±2.6% 200
pdf-lib 40.13ms 45.76ms ±4.0% 13
@cantoo/pdf-lib 39.39ms 45.98ms ±4.0% 13

Create blank PDF

Benchmark Mean p99 RME Samples
libpdf 56μs 126μs ±1.5% 8882
pdf-lib 418μs 1.53ms ±2.5% 1198
@cantoo/pdf-lib 449μs 1.78ms ±2.8% 1113

Add 10 pages

Benchmark Mean p99 RME Samples
libpdf 99μs 163μs ±1.3% 5040
pdf-lib 557μs 2.23ms ±3.3% 899
@cantoo/pdf-lib 505μs 2.61ms ±3.7% 991

Draw 50 rectangles

Benchmark Mean p99 RME Samples
libpdf 342μs 927μs ±1.8% 1462
pdf-lib 1.79ms 7.59ms ±7.4% 279
@cantoo/pdf-lib 2.04ms 5.95ms ±5.9% 246

Load and save PDF

Benchmark Mean p99 RME Samples
libpdf 2.55ms 4.25ms ±3.0% 197
pdf-lib 86.84ms 98.43ms ±4.5% 10
@cantoo/pdf-lib 155.57ms 161.57ms ±2.0% 10

Load, modify, and save PDF

Benchmark Mean p99 RME Samples
libpdf 43.07ms 56.55ms ±7.3% 12
pdf-lib 93.50ms 118.17ms ±9.1% 10
@cantoo/pdf-lib 155.03ms 162.85ms ±1.8% 10

Extract single page from 100-page PDF

Benchmark Mean p99 RME Samples
libpdf 3.66ms 4.39ms ±1.5% 137
pdf-lib 9.21ms 11.70ms ±2.1% 55
@cantoo/pdf-lib 9.83ms 14.98ms ±3.3% 51

Split 100-page PDF into single-page PDFs

Benchmark Mean p99 RME Samples
libpdf 33.65ms 37.68ms ±2.2% 15
pdf-lib 86.28ms 92.86ms ±4.3% 6
@cantoo/pdf-lib 93.60ms 95.55ms ±1.7% 6

Split 2000-page PDF into single-page PDFs (0.9MB)

Benchmark Mean p99 RME Samples
libpdf 627.75ms 627.75ms ±0.0% 1
pdf-lib 1.65s 1.65s ±0.0% 1
@cantoo/pdf-lib 1.69s 1.69s ±0.0% 1

Copy 10 pages between documents

Benchmark Mean p99 RME Samples
libpdf 4.53ms 5.67ms ±1.2% 111
pdf-lib 11.89ms 12.81ms ±1.3% 43
@cantoo/pdf-lib 13.51ms 14.97ms ±2.0% 37

Merge 2 x 100-page PDFs

Benchmark Mean p99 RME Samples
libpdf 14.24ms 16.41ms ±1.6% 36
pdf-lib 53.03ms 53.72ms ±0.5% 10
@cantoo/pdf-lib 63.05ms 65.36ms ±2.0% 8

Fill FINTRAC form fields

Benchmark Mean p99 RME Samples
libpdf 19.84ms 22.71ms ±3.2% 26
pdf-lib 33.89ms 43.37ms ±4.9% 15
@cantoo/pdf-lib 36.07ms 55.87ms ±10.2% 14

Fill and flatten FINTRAC form

Benchmark Mean p99 RME Samples
libpdf 20.18ms 33.50ms ±7.4% 25
pdf-lib FAILED - - 0
@cantoo/pdf-lib 40.15ms 46.30ms ±5.7% 13
Copying

Copy pages between documents

Benchmark Mean p99 RME Samples
copy 1 page 1.05ms 2.41ms ±3.8% 478
copy 10 pages from 100-page PDF 4.56ms 8.35ms ±3.3% 110
copy all 100 pages 7.16ms 7.82ms ±0.9% 70

Duplicate pages within same document

Benchmark Mean p99 RME Samples
duplicate page 0 868μs 1.58ms ±1.1% 576
duplicate all pages (double the document) 886μs 1.80ms ±1.6% 565

Merge PDFs

Benchmark Mean p99 RME Samples
merge 2 small PDFs 1.42ms 2.10ms ±1.2% 353
merge 10 small PDFs 7.34ms 8.34ms ±1.0% 69
merge 2 x 100-page PDFs 13.12ms 16.43ms ±1.5% 39
Drawing

benchmarks/drawing.bench.ts

Benchmark Mean p99 RME Samples
draw 100 rectangles 595μs 1.46ms ±3.2% 840
draw 100 circles 1.27ms 3.09ms ±2.9% 395
draw 100 lines 510μs 1.21ms ±1.6% 980
draw 100 text lines (standard font) 1.59ms 2.52ms ±1.5% 316
create 10 pages with mixed content 1.35ms 2.28ms ±1.7% 372
Forms

benchmarks/forms.bench.ts

Benchmark Mean p99 RME Samples
get form fields 3.36ms 7.84ms ±5.1% 149
fill text fields 11.95ms 17.62ms ±4.9% 43
read field values 2.95ms 4.70ms ±1.5% 170
flatten form 8.16ms 10.94ms ±2.2% 62
Loading

benchmarks/loading.bench.ts

Benchmark Mean p99 RME Samples
load small PDF (888B) 61μs 148μs ±0.9% 8226
load medium PDF (19KB) 96μs 181μs ±0.6% 5225
load form PDF (116KB) 1.34ms 2.44ms ±1.6% 373
load heavy PDF (9.9MB) 2.42ms 3.01ms ±1.0% 207
Saving

benchmarks/saving.bench.ts

Benchmark Mean p99 RME Samples
save unmodified (19KB) 119μs 282μs ±2.7% 4207
save with modifications (19KB) 793μs 2.06ms ±2.2% 631
incremental save (19KB) 179μs 356μs ±2.2% 2796
save heavy PDF (9.9MB) 2.57ms 3.97ms ±1.8% 195
incremental save heavy PDF (9.9MB) 8.69ms 10.27ms ±3.2% 58
Splitting

Extract single page

Benchmark Mean p99 RME Samples
extractPages (1 page from small PDF) 1.01ms 2.40ms ±3.0% 494
extractPages (1 page from 100-page PDF) 3.54ms 4.75ms ±1.4% 142
extractPages (1 page from 2000-page PDF) 56.36ms 57.28ms ±0.5% 10

Split into single-page PDFs

Benchmark Mean p99 RME Samples
split 100-page PDF (0.1MB) 32.30ms 36.69ms ±4.1% 16
split 2000-page PDF (0.9MB) 581.96ms 581.96ms ±0.0% 1

Batch page extraction

Benchmark Mean p99 RME Samples
extract first 10 pages from 2000-page PDF 58.90ms 61.45ms ±1.7% 9
extract first 100 pages from 2000-page PDF 61.47ms 63.99ms ±1.6% 9
extract every 10th page from 2000-page PDF (200 pages) 66.52ms 67.46ms ±1.1% 8
Environment
  • Runner: Linux (X64)
  • Runtime: Bun 1.3.10

Results are machine-dependent.

@Mythie Mythie merged commit a6b2992 into main Mar 11, 2026
6 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.

1 participant