A benchmark of several PHP database abstraction layers.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
doctrine Added doctrine tests Aug 28, 2012
elefant Initial import Aug 28, 2012
idiorm_paris Initial import Aug 28, 2012
redbean Added RedBean Aug 29, 2012
results Added some test results to the readme Sep 12, 2012
README.md Updated readme Sep 12, 2012
index.php Updated index.php to skip lib/ Aug 28, 2012
src.php Initial import Aug 28, 2012



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 direct.php 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

The tests run through the following steps:

  1. Require your database libraries
  2. Connect to your database
  3. Create a basic database schema
  4. Insert 1,000 records with transactions
  5. Count all records broken into 10 queries
  6. Fetch top 50 records
  7. Perform 50 updates
  8. 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.

Frameworks tested

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 example.php into that folder. Edit and name either direct.php or orm.php, depending 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):

PHP Database Library Benchmarks - Numbers

PHP Database Library Benchmarks - Execution Time

PHP Database Library Benchmarks - Memory Usage