Benchmarks#
DBLayer uses PHPBench for benchmark runs.
Purpose#
Benchmarks are intended to track relative change over time for hot paths (builder SQL generation, primary-key lookup flow, transactional read patterns, and focused update behavior). They are not an absolute cross-machine score.
Commands#
composer bench:run
composer bench:quick
composer bench:chart
Current benchmark subjects are defined in benchmarks/DBLayerBench.php:
benchBuildSelectSqlbenchSelectByPrimaryKeybenchTransactionTwoPointReadsbenchUpdateSingleColumnbenchExecuteRawbenchTypedRunCompiledbenchStatementCacheOff/benchStatementCacheOnbenchWithQueryCommentDisabled/benchWithQueryCommentEnabledbenchEventDispatchOff/benchEventDispatchOnbenchSelectRowsBuffered/benchStreamRowsbenchWithLeastLatencyCachedReplica/benchWithLeastLatencyUncachedReplica
Report Interpretation#
Prefer comparing results from the same machine and PHP version.
Watch for drift in mode/mean and RSD.
Use
bench:quickfor local iteration andbench:runfor fuller runs.
Do Not Assume Feature Speedups#
Do not assume statement cache or observability toggles always improve throughput. Compare paired benchmark subjects on the same machine/run:
benchStatementCacheOffvsbenchStatementCacheOnbenchWithQueryCommentDisabledvsbenchWithQueryCommentEnabledbenchEventDispatchOffvsbenchEventDispatchOn
Treat these as measured tradeoffs, not guaranteed improvements.
Chart Output#
bench:chart uses the configured console bar chart generator in
phpbench.json to make regressions easier to spot visually.