A Symfony project for comprehensive performance testing and benchmarking of the Phillarmonic SyncopateBundle, a Symfony integration bundle for SyncopateDB.
This project provides a complete testing environment for evaluating the performance, reliability, and scalability of the SyncopateBundle with varying data loads. It includes data generation commands, benchmarking controllers, and entity models that reflect real-world usage patterns.
- Test Data Generation: Command line tooling to generate configurable amounts of test data
- Performance Benchmarking: API endpoints for measuring various aspects of performance
- Entity Relationships: Complete entity model with relationships matching real-world scenarios
- Memory Usage Testing: Tools for analyzing memory consumption patterns
- Stress Testing: Endpoints for simulating heavy usage scenarios
├── src/
│ ├── Command/
│ │ └── GenerateDataCommand.php # Command to populate test data
│ ├── Controller/
│ │ └── SyncopateBenchmarkController.php # Benchmark API endpoints
│ ├── Entity/
│ │ ├── Category.php
│ │ ├── Order.php
│ │ ├── OrderItem.php
│ │ ├── Product.php
│ │ ├── Review.php
│ │ ├── Tag.php
│ │ └── User.php
│ └── Repository/
│ ├── CategoryRepository.php
│ ├── OrderRepository.php
│ ├── ProductRepository.php
│ ├── ReviewRepository.php
│ └── UserRepository.php
└── vendor/
└── phillarmonic/
└── syncopate-bundle/ # The bundle being tested
-
Clone this repository:
git clone https://github.com/your-organization/syncopate-test-project.git cd syncopate-test-project -
Install dependencies:
composer install
-
Configure your
.envfile with SyncopateDB connection:SYNCOPATE_BASE_URL=http://localhost:8080 SYNCOPATE_TIMEOUT=30 -
Update your
config/packages/phillarmonic_syncopate.yaml:phillarmonic_syncopate: base_url: '%env(SYNCOPATE_BASE_URL)%' timeout: '%env(int:SYNCOPATE_TIMEOUT)%' entity_paths: - '%kernel.project_dir%/src/Entity' auto_create_entity_types: true cache_entity_types: true cache_ttl: 3600
Generate test data using the provided command:
# Generate default amounts of test data
php bin/console app:generate-data
# Generate custom amounts of test data
php bin/console app:generate-data --categories=50 --products=1000 --users=200 --orders=500 --reviews=1000
# Clear existing data before generating new data
php bin/console app:generate-data --clearCommand options:
--categories: Number of categories to create (default: 20)--tags: Number of tags to create (default: 30)--users: Number of users to create (default: 100)--products: Number of products to create (default: 500)--orders: Number of orders to create (default: 200)--reviews: Number of reviews to create (default: 300)--batch: Batch size for processing (default: 20)--clear: Clear existing data before generating new
The benchmark controller provides multiple API endpoints for performance testing:
GET /api/benchmark/dashboard- Overall system stats and entity countsGET /api/benchmark/crud- Basic CRUD operations benchmarkGET /api/benchmark/bulk?count=100- Bulk operations benchmark (configurable count)GET /api/benchmark/query- Query performance benchmarkGET /api/benchmark/join- Join query performance benchmarkGET /api/benchmark/custom-repository- Custom repository methods benchmarkGET /api/benchmark/memory?batch_size=50- Memory usage benchmark (configurable batch size)GET /api/benchmark/stress?iterations=10- Stress test with multiple operationsGET /api/benchmark/raw-query- Raw query options benchmark
Each endpoint returns detailed metrics including:
- Execution time
- Memory consumption
- Result counts
The SyncopateBundle includes a DebugHelper utility class that can be used to troubleshoot memory issues or data type errors. Example:
use Phillarmonic\SyncopateBundle\Util\DebugHelper;
// Get memory usage
$memoryUsage = DebugHelper::getMemoryUsage();
// Check array for problematic data types
$issues = DebugHelper::checkArrayForProblematicTypes($data);
// Enable debug mode
DebugHelper::enableDebug();
// Set custom logging
DebugHelper::setLogCallback(function($message, $context) {
// Your custom logging here
});This project demonstrates several strategies for optimizing performance with SyncopateDB:
- Batch Processing: Load large datasets in smaller batches
- Memory Management: Explicitly release memory with
unset()andgc_collect_cycles() - Optimized Queries: Use specific query filters to reduce result sets
- Join Optimization: Structure joins for optimal performance
The test project includes the following entities with relationships:
- Category: Hierarchical structure with parent/child relationships
- Product: Belongs to category, has many reviews
- User: Has many orders and reviews
- Order: Belongs to user, has many order items
- OrderItem: Belongs to order, references a product
- Review: Belongs to user and product
- Tag: Many-to-many with products
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open-sourced software licensed under the MIT license.