Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/compositephp/php-datamapper-benchmark
PHP ORM Performance Analysis: Benchmarking and comparing Doctrine, Laravel, Cycle, and CompositePHP ORMs in CRUD operations on MySQL. Essential insights on speed and memory efficiency for PHP developers.
https://github.com/compositephp/php-datamapper-benchmark
Last synced: about 1 month ago
JSON representation
PHP ORM Performance Analysis: Benchmarking and comparing Doctrine, Laravel, Cycle, and CompositePHP ORMs in CRUD operations on MySQL. Essential insights on speed and memory efficiency for PHP developers.
- Host: GitHub
- URL: https://github.com/compositephp/php-datamapper-benchmark
- Owner: compositephp
- Created: 2023-12-25T15:35:38.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2024-07-13T21:45:32.000Z (4 months ago)
- Last Synced: 2024-07-13T22:38:45.519Z (4 months ago)
- Language: PHP
- Size: 10.7 KB
- Stars: 4
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PHP DataMappers Benchmark
## Overview
This repository contains benchmarks for some of the most popular PHP DataMapper's, used as a reference for performance
optimizations in my personal project [compositephp/db](https://github.com/compositephp/db).The projects benchmarked include:
- [Doctrine](https://www.doctrine-project.org/)
- [Laravel Eloquent](https://laravel.com/docs/8.x/eloquent)
- [Cycle ORM](https://cycle-orm.dev/)
- [Composite DB](https://github.com/compositephp/db/)
- [PHPFUI ORM](https://github.com/phpfui/ORM)## Methodology
* The benchmark executes 10 000 CRUD (Create, Read, Update, Delete) operations to assess the performance.
* The benchmark tests focus exclusively on the 'DataMapper' component of each project, employing simple queries that do
not involve relationships, foreign keys, or joins.Operations include:
1. Creating a new record in the database.
2. Reading the record by primary key.
3. Updating one field for the found record.
4. Deleting the record.### Database
- MySQL 8.0
- Table used for the benchmark:
```sql
CREATE TABLE IF NOT EXISTS Users
(
`id` INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL,
`age` INTEGER NOT NULL,
`microtime` FLOAT NOT NULL,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL
);
```## Results
### MacBook Pro with Apple M2 Pro Chip and 12‑Core CPU:
| Project | Time (seconds) | Memory Kb | Memory Peak Mb |
|------------------|----------------|-----------|----------------|
| Laravel Eloquent | 61.51 | 4950.91 | 8.063 |
| Cycle ORM | 44.32 | 288.15 | 7.007 |
| Doctrine | 37.45 | 870.24 | 6.408 |
| CompositeDB | 24.71 | 143.46 | 2.217 |
| PHPFUI ORM | 20.43 | 109.37 | 2.196 |## Running Locally
### Requirements
* PHP 8.1+
* Docker
* Composer
* PDO_MySQL extension### Steps
1. Clone or download this repository
2. Run `composer update`
3. Execute `docker-compose up`
4. Run benchmarks for each DataMapper separately:
* `php src/test-laravel.php`
* `php src/test-cycle.php`
* `php src/test-doctrine.php`
* `php src/test-composite.php`
* `php src/test-PHPFUI.php`## Note
This is a synthetic benchmark focused on speed and memory consumption and does not compare the feature list of the projects.
Feel free to note any problems, inaccuracies, or shortcomings in using these projects and make a pull request to fix them.