Skip to content

Add a base64 micro benchmark - #17

Open
lemire wants to merge 1 commit into
kocsismate:mainfrom
lemire:base64-bench
Open

lemire wants to merge 1 commit into
kocsismate:mainfrom
lemire:base64-bench

Conversation

@lemire

@lemire lemire commented Nov 17, 2026

Copy link
Copy Markdown

This adds base64_bench.php, a micro test for base64_encode() and base64_decode() that may better cover how base64 is used in practice:

  • short tokens (16 and 32 bytes), encoding and decoding, including strict mode
  • 1 KiB payloads
  • a 64 KiB attachment, both plain and MIME-style (CRLF every 76 characters)
  • a 1 MiB blob
  • 1,000 strings with sizes spread log-uniformly between 1 byte and 8 KiB
  • JWT decoding with the usual strtr() base64url idiom
  • data URI round trips on 1–16 KiB images

All inputs are generated at runtime from a fixed seed, so the calls cannot be evaluated at compile time. Before timing, the script checks that the results are correct, and the expectation file asserts that the check passed.

The configuration follows micro_bench.php (5 warmups, 50 iterations, 1 request). Each workload takes roughly 30–110 ms on current master on a recent Xeon, about 1.1 s in total.

This was written to evaluate php/php-src#25476.

This branch has not been deployed

No deployments
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