PhpRiot
News Archive
PhpRiot Newsletter
Your Email Address:

More information

Damian Sromek's Blog: [How to] Run PHPUnit tests using database 10x faster

Note: This article was originally published at PHPDeveloper on 7 January 2011.
PHPDeveloper

Damian Sromek has a helpful unit testing hint for those working with database-heavy tests - less about code, more about server setup.

PHPUnit tests that are heavily using the database can run like 10x faster when you run the database from the RAMDisk. It's the easiest way I know to improve the speed of the tests execution.

Because of the slowness that could be caused by running unit tests that rely heavily on the database, he suggests setting up a testing instance on a RAMDisk (or something similar). The speed difference he noticed was huge with his tests normally running about 25 minutes. Moving it over to the RAM disk dropped their execution time down to around 2:30, a jump of around 10 times faster.