Add benchmarks#294
Conversation
samdark
commented
Jan 6, 2026
| Q | A |
|---|---|
| Is bugfix? | ❌ |
| New feature? | ❌ |
| Breaks BC? | ❌ |
| Fixed issues | - |
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive performance benchmarking infrastructure to the project using PHPBench. It introduces 8 benchmark classes covering various rendering scenarios, configuration files, documentation, and CI workflow integration.
Key Changes:
- Added 8 benchmark classes for testing different view rendering scenarios (basic views, nested views, themes, locales, assets, blocks, and multiple renderers)
- Configured PHPBench with phpbench.json and added composer script for running benchmarks
- Added GitHub Actions workflow for automated benchmark execution on pull requests and pushes
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Benchmark/WebViewBench.php | Benchmark for WebView layout rendering |
| tests/Benchmark/WebViewAssetsBench.php | Benchmark for WebView with asset registration (CSS/JS files and strings) |
| tests/Benchmark/ViewThemeBench.php | Benchmark for themed view rendering |
| tests/Benchmark/ViewLocaleBench.php | Benchmark for localized view rendering |
| tests/Benchmark/ViewBasicBench.php | Benchmark for simple view rendering without additional features |
| tests/Benchmark/NestedViewsBench.php | Benchmark for nested view rendering scenarios |
| tests/Benchmark/MultiRendererBench.php | Benchmark for multiple template renderers (PHP, Blade, TPL) |
| tests/Benchmark/BlocksBench.php | Benchmark for view blocks functionality |
| phpbench.json | PHPBench configuration with 1000 revisions and 10 iterations |
| composer.json | Added phpbench dependency and bench script |
| .github/workflows/benchmark.yml | CI workflow for running benchmarks on Ubuntu and Windows with PHP 8.1 |
| docs/internals.md | Documentation for running benchmarks |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #[Bench\BeforeMethods(['prepareView'])] | ||
| public function prepareView(): void |
There was a problem hiding this comment.
The BeforeMethods attribute references 'prepareView' which is the same method being annotated. This creates a recursive call that will cause an infinite loop. The attribute should either be removed or reference a different setup method.
| $this->preparedView = $this->view; | ||
| } | ||
|
|
There was a problem hiding this comment.
The property 'preparedView' is declared as non-readonly but is initialized with a readonly property 'view' in the constructor. This assignment doesn't provide any value since both properties reference the same instance at construction time. Consider removing line 19 or initializing 'preparedView' differently if it's meant to be modified later.
| $this->preparedView = $this->view; | |
| } | |
| } |
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** @var \Yiisoft\View\View $this */ | ||
|
|
||
| echo 'PHP view'; | ||
| PHP_WRAP |
There was a problem hiding this comment.
The heredoc content has inconsistent leading whitespace. Lines 28-33 have excessive leading spaces that will be included in the file content, which may not be intended.
| <?php | |
| declare(strict_types=1); | |
| /** @var \Yiisoft\View\View $this */ | |
| echo 'PHP view'; | |
| PHP_WRAP | |
| <?php | |
| declare(strict_types=1); | |
| /** @var \Yiisoft\View\View $this */ | |
| echo 'PHP view'; | |
| PHP_WRAP |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #294 +/- ##
=========================================
Coverage 99.50% 99.50%
Complexity 305 305
=========================================
Files 19 19
Lines 801 801
=========================================
Hits 797 797
Misses 4 4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|