What about the DI container performance?
Full disclosure: beside some common known good practices I’m a lame developer performance wise.
In a WordPress echo system I know I should not make the same query twice, avoid any kind of data manipulation when necessary and so on.
But deep down at the “let’s use this function in place of this one” level my knowledge is scarce to say the least.
Lucky me I came across this Sitepoint article by Tom Butler and had my mind blown.
I’m relying on my PHP 5.2 compatible dependency injection container solution more and more and taking a look at how it performs might be a good thing to do.
Part of it is that I’m just curious.
The article points a GitHub repository and it took little time to have it up and working as I needed it to.
To narrow down the results I’ve decided to benchmark DI52 against the DI container that came out as the fastest one in the article, Dice by Tom Butler himself, and the one that inspired me (“the one I’ve blatantly copied”): the Laravel one.
I’ve left the other libraries for referencing purposes. After some local set up the repo requires I was able to run the comparative tests using DI52 in its basic form; I’ve ran the first 5 tests for the time being and created the needed test files.
See them on my fork here; test1, test 2, test 3, test 4 and test 5.
The test results are on GitHub as well but here’s a quick screenshot after a run on my local machine: A look at the tests reveals that, in the synthetic context of the tests, DI52 is in the “not so good, not so bad” position. There is room for improvement though so down to work.
I will explore and chronicle my quest for performance and with it my utter ignorance about it.