Skip to content

Latest commit

Β 

History

211 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

⚑ PHP Benchmark Suite

Code Quality PHP Version PHPStan Level License

A modern benchmarking framework for PHP testing performance across versions 5.6 to 8.5

Features β€’ Installation β€’ Usage β€’ Architecture β€’ Contributing


✨ Features

🎯 Performance Testing

  • 107+ Benchmarks covering arrays, strings, loops, OOP, functions, and more
  • Statistical Analysis with percentiles (p50, p80, p90, p95, p99)
  • Memory Profiling tracks memory usage and peaks

πŸ”„ Version Comparison

  • Multi-Version Testing from PHP 5.6 to 8.5
  • Visual Charts compare performance across versions
  • Evolution Tracking see how PHP improves over time

⚑ High Performance

  • Asynchronous Processing with Symfony Messenger and Redis queue
  • Docker Isolation each version in isolated containers
  • Event-Driven Architecture for extensibility

πŸ—οΈ Modern Architecture

  • Clean Architecture with DDD + Hexagonal design
  • SOLID Principles validated by PHPStan level max
  • Architecture Tests enforced by PHPArkitect

πŸ“Š Web Dashboard

  • Interactive Charts powered by Chart.js
  • Live Progress watch benchmarks execute in real-time
  • Detailed Stats view execution times, memory, percentiles

🎨 Easy Customization

  • YAML Fixtures define benchmarks in simple YAML files
  • Database Storage benchmarks persisted in MariaDB
  • Hot Reload add new benchmarks without code changes

πŸ“‹ Requirements

Requirement Version Purpose
Docker Latest Container runtime
Docker Compose v2+ Multi-container orchestration
Make Any Task automation (optional)

πŸš€ Installation

git clone https://github.com/jblairy/php-benchmark.git
cd php-benchmark
make up              # Start Docker containers
make db.refresh      # Create database and load benchmark fixtures

The make db.refresh command will:

  1. Create the MariaDB database
  2. Run migrations to create tables
  3. Load 100+ benchmark definitions from YAML fixtures

πŸ’» Usage

Quick Start

# Run all benchmarks
make run

# View results in browser
open http://localhost/dashboard

Advanced Usage

Run Specific Benchmark
# Run a specific test
make run test=Loop

# Run with custom iterations
make run test=Loop iterations=100

# Run on specific PHP version
docker-compose run --rm main php bin/console benchmark:run \
  --test=Loop \
  --php-version=php84 \
  --iterations=10
Development Commands
# Database management
make db.reset          # Drop and recreate database (empty)
make db.refresh        # Reset database + load fixtures
make fixtures          # Load benchmark fixtures only

# Testing
make test              # Run all PHPUnit tests (50 tests, 212 assertions)
make test-coverage     # Run tests with coverage report

# Code Quality
make phpstan           # Static analysis (level max)
make phpcsfixer        # Check code style (PSR-12)
make phpcsfixer-fix    # Fix code style automatically
make quality           # Run all quality checks

# Assets (CSS/JS)
make assets.refresh    # Rebuild and refresh frontend assets

# Translations (i18n)
make trans.compile     # Compile YAML β†’ XLF (2-3x faster, production-ready)
make trans.update      # Extract new keys from templates + compile

πŸ“Š View Results

Access the web dashboard to explore benchmark results:

  • URL: http://localhost/dashboard
  • Features: Interactive charts, live progress tracking, detailed statistics

πŸ—οΈ Architecture

This project follows Clean Architecture principles with Domain-Driven Design (DDD) and Hexagonal Architecture (Ports & Adapters).

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Infrastructure                        β”‚
β”‚  (Symfony, Doctrine, Docker, Web, CLI, Persistence)    β”‚
β”‚                           ↓                              β”‚
β”‚                      Application                         β”‚
β”‚              (Use Cases, Orchestration)                  β”‚
β”‚                           ↓                              β”‚
β”‚                        Domain                            β”‚
β”‚          (Business Logic - Pure PHP)                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Directory Structure

src/
β”œβ”€β”€ Domain/                     # 🎯 Core Business Logic (Framework-free)
β”‚   β”œβ”€β”€ Benchmark/             # Benchmark models, value objects, ports
β”‚   β”œβ”€β”€ Dashboard/             # Dashboard domain models, statistics
β”‚   └── PhpVersion/            # PHP version enumeration
β”‚
β”œβ”€β”€ Application/               # πŸ“¦ Use Cases (Orchestration Layer)
β”‚   β”œβ”€β”€ UseCase/               # Benchmark execution orchestration
β”‚   └── Dashboard/             # Dashboard data aggregation
β”‚
└── Infrastructure/            # πŸ”§ Technical Implementation
    β”œβ”€β”€ Async/                 # Event dispatcher and message bus adapters
    β”œβ”€β”€ Cli/                   # Symfony Console commands
    β”œβ”€β”€ Execution/             # Docker script execution
    β”œβ”€β”€ Persistence/           # Doctrine entities, repositories, fixtures
    └── Web/                   # Symfony controllers, components, Twig

Key Principles

  • βœ… Dependencies flow inward: Infrastructure β†’ Application β†’ Domain
  • βœ… Domain is framework-agnostic: Pure PHP, no Symfony/Doctrine dependencies
  • βœ… Ports & Adapters: Domain defines interfaces (Ports), Infrastructure implements them (Adapters)
  • βœ… Validated by PHPArkitect: Architecture rules are enforced automatically

πŸ“š Documentation

Document Description
docs/architecture/01-overview.md Architecture deep dive
docs/architecture/02-layers.md Layer responsibilities
docs/architecture/03-ports-adapters.md Hexagonal architecture details
AGENTS.md Developer reference guide
docs/README.md Complete documentation index

🀝 Contributing

We love contributions! Whether it's bug fixes, new benchmarks, or documentation improvements, all contributions are welcome.

Contribution Guidelines

πŸ“ Code Style Follow PSR-12 standards (enforced by PHP-CS-Fixer)
πŸ” Static Analysis Pass PHPStan level max (strictest level)
πŸ—οΈ Architecture Respect Clean Architecture principles (validated by PHPArkitect)
βœ… Testing Write PHPUnit tests for new features
🌐 Language Write all code, comments, docs, commits, PRs in English
πŸ“š Documentation Document your benchmarks and architectural decisions

Development Workflow

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run quality checks: make quality
  5. Run tests: make test
  6. Commit your changes (see Atomic Commits Guide)
  7. Push to your branch (git push origin feature/amazing-feature)
  8. Open a Pull Request

Quick Quality Check

# Run all quality checks before committing
make quality

# This runs:
# βœ“ PHPStan (static analysis)
# βœ“ PHP-CS-Fixer (code style)
# βœ“ PHPUnit (tests)
# βœ“ PHPMD (mess detection)
# βœ“ PHPArkitect (architecture validation)

πŸ“– Developer Resources

🎯 Creating Custom Benchmarks

Benchmarks are defined as YAML files in fixtures/benchmarks/. No PHP code changes needed!

Click to see example benchmark
# fixtures/benchmarks/my-benchmark.yaml
slug: my-benchmark
name: 'My Custom Benchmark'
category: 'Custom'
description: 'Description of what this benchmark tests'
icon: πŸš€
tags:
  - custom
  - performance
phpVersions:
  - php84
  - php85
code: |
  // Your benchmark code here
  $result = [];
  for ($i = 0; $i < 10000; $i++) {
      $result[] = $i * 2;
  }

Load the new benchmark:

make fixtures   # Load fixtures only
# or
make db.refresh # Reset database + reload all benchmarks

πŸ“– Full guide: docs/guides/creating-benchmarks.md

πŸ› οΈ Tech Stack

PHP
PHP 8.4+
Symfony
Symfony 7.2
Doctrine
Doctrine ORM
Docker
Docker
MariaDB
MariaDB
Chart.js
Chart.js
Stimulus
Stimulus

Quality Tools

Tool Purpose Level/Standard
PHPStan Static analysis Level max (strictest)
PHP-CS-Fixer Code style PSR-12 + Symfony
PHPUnit Unit testing 50 tests, 212 assertions
PHPArkitect Architecture validation Clean Architecture rules
PHPMD Mess detection Custom ruleset
Infection Mutation testing Available

πŸ“Š Project Stats

  • 🎯 Benchmarks: 107 automated tests
  • βœ… Tests: 50 passing (212 assertions)
  • πŸ“ Code Quality: PHPStan level max, PSR-12 compliant
  • πŸ—οΈ Architecture: Clean Architecture + DDD + Hexagonal
  • πŸ”„ PHP Versions: Supports 5.6 to 8.5
  • πŸ“š Documentation: 15+ detailed guides and ADRs

πŸ“„ License

This project is licensed under the MIT License. See the LICENSE file for details.

πŸ™ Acknowledgments

  • PHP Community - For continuous inspiration and improvements
  • Contributors - Thank you to everyone who has contributed to this project
  • Open Source Projects - Built on the shoulders of giants

Key Dependencies

Special thanks to the maintainers of:

πŸ“ž Support & Community

πŸ› Issues Report bugs or request features
πŸ’¬ Discussions Ask questions and share ideas
πŸ“§ Contact Reach out via GitHub issues or discussions

🌟 Show Your Support

If this project helped you, please consider:

  • ⭐ Star this repository on GitHub
  • πŸ”€ Fork and contribute
  • πŸ“’ Share with the PHP community
  • πŸ’‘ Open issues for improvements

Made with ❀️ for the PHP Community

GitHub stars GitHub forks GitHub watchers

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages