This is an attempt to benchmark several PHP database abstraction layers.
Where one offers ORM, there will be an orm.php in addition to a
file with the tests for that library.
To run, drop the
php-dbal-bench folder into your site root and load
/php-dbal-bench/ in your web browser.
The tests run through the following steps:
- Require your database libraries
- Connect to your database
- Create a basic database schema
- Insert 1,000 records with transactions
- Count all records broken into 10 queries
- Fetch top 50 records
- Perform 50 updates
- Perform 50 deletes
Any test is flawed and this is no exception, but this does show all of the basic uses and gives a sense of how well each library performs at them.
Creating new tests
The tests should be run on an in-memory SQLite database to have a common
baseline. To create a new test, create a folder for it and copy
into that folder. Edit and name either
on the type of database abstraction layer used.
I ran the tests on an iMac with 3.06 GHz Intel Core 2 Duo with 8 GB RAM running PHP 5.3.10 with APC enabled and Apache 2.2.21. Here are the numbers and charts of the execution time and memory usage breakdown (click each graphic to view it in full size):