NAME

problem48-stash-decode-benchmark - compare the legacy STASH decoder cost

PURPOSE

Measures repeated decoding of one deterministic legacy Perl-literal STASH through Developer::Dashboard::PageDocument::_decode_stash_section and verifies that each measured run produces the same canonical JSON value.

WHY IT EXISTS

Problem 48 requires subroutine-specific performance evidence. The legacy decoder uses Safe for Perl-literal compatibility; current source may use its bounded JSON-snapshot memoization for repeated identical values. This tool isolates that call without changing application files or fixtures.

WHEN TO USE

Run when changing the legacy STASH parser, its memoization bounds, cache copying behavior, or the source-version comparison procedure. It is a focused microbenchmark and does not represent whole-route latency.

HOW TO USE

Run both source trees in the development container, selecting each library with P48_LIB:

d2 docker compose exec dev env P48_LIB=/work/nytprof/v588/lib perl script/problem48-stash-decode-benchmark --iterations 3000 --runs 21
d2 docker compose exec dev env P48_LIB=/work/lib perl script/problem48-stash-decode-benchmark --iterations 3000 --runs 21

--iterations must be positive. --runs must be a positive odd integer so the reported median is a sample value. The benchmark dies if source selection, decoding, or exact serialized-result parity fails.

WHAT USES IT

The Problem 48 performance investigation uses this script after its regression tests pass, comparing the v5.88 baseline tree with the current repository.

EXAMPLES

Print usage without running a measurement:

perl script/problem48-stash-decode-benchmark --help

Measure 3,000 calls across 21 samples for one selected source tree:

P48_LIB=/work/lib perl script/problem48-stash-decode-benchmark --iterations 3000 --runs 21

OUTPUT

The first line records the resolved source library, workload size, and median microseconds per call. The second line reports a SHA-256 digest of the canonical decoded value and confirms repeat parity.