NAME
problem48-class-method-benchmark - compare builtin Perl classes with blessed hashes
PURPOSE
Measures repeated method dispatch and field reads on one object implemented with Perl's builtin class/field/method syntax, compared with blessed hash objects using ordinary @_ access and a lexical subroutine signature. All three methods return the same scalar value on every iteration.
WHY IT EXISTS
Problem 48 explicitly evaluates builtin class syntax as a performance option. This benchmark determines whether its method and field access is faster before considering any production object migration.
WHEN TO USE
Run in the isolated Problem 48 Docker image with Perl 5.40 or newer, where the builtin class feature is available. This is a microbenchmark, not evidence for all Dashboard methods or routines.
HOW TO USE
perl script/problem48-class-method-benchmark
perl script/problem48-class-method-benchmark --iterations 1000000 --runs 9
The run count must be an odd positive integer. Each timed sample verifies that the accumulated field value matches the expected result. Sample start order rotates between the three implementations to reduce order bias.
WHAT USES IT
Problem 48 performance research uses this script to assess builtin class dispatch against the current blessed-hash object style. Application code and the release workflow do not invoke it.
EXAMPLES
d2 docker compose --service bench -f /tmp/d2-problem48-bench.yml --project-name dd-problem48-profile-next run --rm bench perl script/problem48-class-method-benchmark