Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test3.php #19

Open
mindplay-dk opened this issue Aug 22, 2015 · 2 comments
Open

test3.php #19

mindplay-dk opened this issue Aug 22, 2015 · 2 comments

Comments

@mindplay-dk
Copy link

I don't think "test3.php" benchmarks what you think it does - at least, after looking at implementations for pimple and php-di, in both cases, as far as I can tell, you're not benchmarking the time taken to create the object graph at all.

For instance, here in php-di/test3.php you've already resolved the object graph when you triggered the autoloader. Since you continue benchmarking the same container, the object graph has already been resolved, so all it's doing in the loop, is a key lookup.

pimple/test3.php is a different benchmark entirely - here, you're actually creating a new container every time, inside the loop, triggering an actual resolve of the object graph.

league/test3.php also appears to resolve the object graph outside of the loop.

I'm trying to write the benchmark for my own container, but how is it supposed to work? Which of the benchmarks should I be using as point of reference?

@TRPB
Copy link
Owner

TRPB commented Aug 22, 2015

Well spotted, I think you're right about pimple and I'll update it.

However, the test itself is correct, it should be creating a new object graph on each iteration. So for example, looking at League

https://github.com/TomBZombie/php-dependency-injection-benchmarks/blob/master/league/test3.php#L11

$one = $container->get('J');
$two = $container->get('J');

var_dump($one === $two) should evaluate to false, similarly, $one->i === $two->i should evaluate to false.

edit: If all php-di is doing is a key lookup it's doing it incredibly inefficiently!

@mnapoli
Copy link
Contributor

mnapoli commented Aug 22, 2015

For the PHP-DI test, see the config file -> it will return a new instance every time so the behavior should be inline with the other tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants