The original post: /r/php by /u/lankybiker on 2024-12-14 11:41:06.

Had an idea

Many code bases get very slow when the database gets big. But many test driven code bases use small or even microscopic databases when running tests.

You could always create a massive database for testing but that brings a lot of problems

How about something that wraps pdo etc and examines the SQL. If the query seems complex then a delay is calculated and then a micro sleep is called before returning results.

Then in integration tests, you can use phpunits time limit functionality to enforce time limits, or maybe something more precise can be used

This way you can still use a tiny test DB but still get useful feedback on areas of the code base that are going to be problematic with large database

Obviously the trick will be creating meaningful and accurate delay calculation based on the SQL. I wonder if this has been done before somewhere?