PHP Vitals is a comprehensive benchmarking tool that helps you understand and optimize your PHP environment's performance. Let's explore how it works and how to interpret its results.
Quick Start
- Download the
phpvitals.php
script - Upload it to your web server
- Access it via browser:
https://yoursite.com/phpvitals.php
- Wait for the tests to complete
What Gets Tested?
Base PHP Tests
These core tests evaluate your basic PHP performance:
-
PHP Features
- Class instantiation
- Method calls
- Property access
- Exception handling
-
Mathematical Operations
// Example of math operations tested $result = 0; for ($i = 0; $i < 1000000; $i++) { $result += ($i * $i) / 2; }
-
String Operations
- String concatenation
- String manipulation
- Regular expressions
- Character encoding
-
Array Operations
- Array creation and destruction
- Array manipulation (push, pop, merge)
- Array sorting and searching
- Array to string conversions
Extension Tests
Additional tests for common PHP extensions:
-
Image Processing
- GD operations
- ImageMagick operations (if available)
- Image resizing and manipulation
-
Compression
- Gzip compression
- Bzip2 compression
- Zip operations
-
Serialization
- PHP serialization
- JSON encoding/decoding
- igbinary (if available)
- MessagePack (if available)
Understanding Results
Time Score
The script measures execution time for each test:
- A+ Grade (< 3s): Exceptional performance
- A Grade (3-5s): Excellent performance
- B Grade (5-10s): Good performance
- C Grade (10-15s): Average performance
- D Grade (15-20s): Below average
- F Grade (> 20s): Poor performance
Operations per Second
Each test reports operations per second (op/s):
Test Name | Time | Op/s | Op/s/MHz
-----------|---------|--------|----------
Math Test | 0.0234s | 42,735 | 10.68
String Test| 0.0456s | 21,929 | 5.48
Array Test | 0.0789s | 12,674 | 3.17
CPU Normalization
The Op/s/MHz metric helps compare results across different CPU speeds:
- Higher numbers indicate better efficiency
- Useful for comparing different servers
- Helps identify bottlenecks
Common Performance Issues
-
Slow Math Operations
- Check OpCache settings
- Verify CPU governor settings
- Monitor CPU throttling
-
Poor String Performance
- Check memory settings
- Verify character encoding settings
- Monitor memory fragmentation
-
Slow Array Operations
- Adjust memory_limit
- Check for memory leaks
- Monitor garbage collection
Optimization Tips
Based on test results:
- Enable OpCache
opcache.enable=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.validate_timestamps=0
opcache.revalidate_freq=0
opcache.fast_shutdown=1
- Adjust Memory Settings
memory_limit = 256M
realpath_cache_size = 4096K
realpath_cache_ttl = 600
- Enable JIT (PHP 8+)
opcache.jit_buffer_size=100M
opcache.jit=1235
Comparing Results
The script automatically submits anonymous results to our database, allowing you to:
- Compare your scores with similar environments
- Track performance changes over time
- Identify potential improvements
Troubleshooting
If you encounter issues:
-
Script Timeout
- Increase max_execution_time
- Run fewer tests simultaneously
-
Memory Errors
- Increase memory_limit
- Monitor memory usage
-
Extension Errors
- Verify required extensions
- Check extension compatibility
Next Steps
- Run the benchmark on your server
- Compare results with our baseline
- Implement recommended optimizations
- Re-run tests to verify improvements
Remember, performance optimization is an ongoing process. Regular benchmarking helps maintain optimal performance as your application evolves.