Comprehensive performance testing suite for the timetracker export functionality, focusing on Excel generation, data processing, and JIRA integration performance characteristics.
The export functionality is performance-critical as it processes large datasets and generates complex Excel files with PhpSpreadsheet. This test suite provides:
- Performance benchmarking for different data volumes
- Memory usage analysis and optimization validation
- Regression detection through historical comparison
- Stress testing for edge cases and large datasets
- End-to-end integration testing with real database operations
- Purpose: Tests ExportService performance in isolation
- Coverage: Data export, ticket enrichment, memory scaling
- Scenarios:
- Small dataset (50 entries) - baseline performance
- Medium dataset (500 entries) - realistic load
- Large dataset (5000 entries) - stress testing
- Ticket enrichment with JIRA API simulation
- Memory usage scaling analysis
- Purpose: Tests complete Excel generation pipeline
- Coverage: PhpSpreadsheet processing, template loading, statistics
- Scenarios:
- Excel generation with different data volumes
- Template processing performance
- Memory usage during Excel creation
- File size scaling analysis
- Statistics calculation performance
- Purpose: End-to-end workflow testing with real database
- Coverage: HTTP requests, database queries, complete pipeline
- Scenarios:
- Full export workflow via HTTP
- Database query performance
- Concurrent request handling
- Filter combinations impact
- Large dataset memory management
Performance thresholds are configured to detect regressions:
| Scenario | Time Threshold | Memory Threshold | Notes |
|---|---|---|---|
| Small Dataset Export | 100ms | 5MB | 50 entries baseline |
| Medium Dataset Export | 500ms | 25MB | 500 entries realistic |
| Large Dataset Export | 2000ms | 50MB | 5000 entries stress test |
| Ticket Enrichment | 1000ms | - | 100 tickets with JIRA |
| Excel Generation Small | 500ms | 25MB | With PhpSpreadsheet |
| Excel Generation Large | 10000ms | 100MB | 5000 entries + Excel |
| End-to-End Small | 1000ms | - | HTTP + DB + Excel |
| End-to-End Medium | 3000ms | - | Full pipeline |
# Run ExportService performance tests
php bin/phpunit tests/Performance/ExportPerformanceTest.php
# Run ExportAction performance tests
php bin/phpunit tests/Performance/ExportActionPerformanceTest.php
# Run integration performance tests
php bin/phpunit tests/Performance/ExportWorkflowIntegrationTest.php# Run all performance tests with detailed reporting
php bin/phpunit --group=performance
# Run benchmark runner for comprehensive analysis
php tests/Performance/PerformanceBenchmarkRunner.php
# Run with custom report location
php tests/Performance/PerformanceBenchmarkRunner.php /path/to/custom/report.jsonAdd to composer.json for convenience:
{
"scripts": {
"perf:export": "APP_ENV=test php bin/phpunit --group=performance tests/Performance/",
"perf:benchmark": "APP_ENV=test php tests/Performance/PerformanceBenchmarkRunner.php",
"perf:report": "APP_ENV=test php tests/Performance/PerformanceBenchmarkRunner.php var/performance-report.json"
}
}- Execution Time: Processing duration in milliseconds
- Memory Usage: Peak and delta memory consumption
- Throughput: Records processed per second
- File Size: Generated Excel file size scaling
- Database Performance: Query execution time
The benchmark runner automatically detects performance regressions by comparing with historical data:
- Execution Time: >20% increase triggers warning
- Memory Usage: >25% increase triggers warning
- Throughput: >15% decrease triggers warning
Historical data is stored in var/performance-history.json (last 10 runs).
Generated reports include:
- Machine-readable format for CI/CD integration
- Complete benchmark data with timestamps
- Suitable for trend analysis and dashboards
- Human-readable summary format
- Performance statistics and regression warnings
- Ideal for development team review
Based on benchmark analysis, key optimization opportunities:
- Current: Multiple queries for relationships
- Target: Optimized joins and eager loading
- Impact: Reduce query count by 60-80%
- Current: Full dataset loaded into memory
- Target: Streaming/batch processing
- Impact: Reduce memory usage by 40-60%
- Current: Row-by-row cell population
- Target: Bulk data insertion with arrays
- Impact: Reduce Excel generation time by 30-50%
- Current: Individual API calls per ticket
- Target: Batch JIRA API requests
- Impact: Reduce enrichment time by 70-80%
Recommended CI/CD pipeline integration:
# Example GitHub Actions step
- name: Run Performance Tests
run: |
composer perf:benchmark
# Fail build if critical regressions detected
if grep -q "execution time increased by [3-9][0-9]%" var/performance-report*.txt; then
echo "Critical performance regression detected"
exit 1
fi- Store historical reports in artifact repository
- Set up alerts for regression thresholds
- Generate trend analysis dashboards
- Include performance metrics in release notes
- Before release: Full benchmark suite
- After export changes: Related performance tests
- Weekly: Regression monitoring
- After infrastructure changes: Complete validation
- Update baselines when hardware/infrastructure changes
- Adjust thresholds based on acceptable performance criteria
- Add new scenarios for new export features
- Archive old reports to prevent disk usage growth
- Identify bottlenecks using detailed benchmark reports
- Profile with Xdebug for deep analysis of slow components
- Use database query logs to identify slow queries
- Monitor memory usage patterns for optimization opportunities
- Test with production-like data volumes for realistic analysis
- Data Volume: Export time scales roughly O(n) with entry count
- Excel Complexity: Memory usage scales with worksheet complexity
- Ticket Enrichment: Network latency impacts greatly with many tickets
- Concurrent Users: Memory pressure increases with simultaneous exports
Consider implementing:
- Export request duration monitoring
- Memory usage tracking for large exports
- Queue-based processing for very large exports
- Export result caching for repeated requests
- Asynchronous Processing: Queue large exports for background processing
- Streaming Responses: Stream Excel generation to reduce memory usage
- Result Caching: Cache export results for repeated identical requests
- Database Optimization: Implement more efficient queries and indexes
- Partial Loading: Load and process data in chunks rather than full datasets
- Load Testing: Simulate multiple concurrent export requests
- Stress Testing: Test with extremely large datasets (50k+ entries)
- Network Simulation: Test JIRA integration with various network conditions
- Resource Constraints: Test with limited memory/CPU resources