}; $phpdi_configuration = function () { $container = (require __DIR__ . '/bootstrap-php-di.php'); }; $pimple_configuration = function () { $container = (require __DIR__ . '/bootstrap-pimple.php'); }; $bench->add('unbox: configuration', $unbox_configuration); $bench->add('php-di: configuration', $phpdi_configuration); $bench->add('pimple: configuration', $pimple_configuration); $bench->run(); foreach (array(1, 3, 5, 10) as $num) { $bench = new Benchmark(); $bench->add("unbox: {$num} repeated resolutions", function () use($num) { $container = (require __DIR__ . '/bootstrap-unbox.php'); for ($i = 0; $i < $num; $i++) { $cache = $container->get(UserRepository::class); } }, $unbox_configuration); $bench->add("php-di: {$num} repeated resolutions", function () use($num) { $container = (require __DIR__ . '/bootstrap-php-di.php'); for ($i = 0; $i < $num; $i++) { $cache = $container->get(UserRepository::class); } }, $phpdi_configuration); $bench->add("pimple: {$num} repeated resolutions", function () use($num) { $container = (require __DIR__ . '/bootstrap-pimple.php'); for ($i = 0; $i < $num; $i++) { $cache = $container[UserRepository::class]; } }, $pimple_configuration); $bench->run();
<?php use mindplay\benchpress\Benchmark; require __DIR__ . '/header.php'; $bench = new Benchmark(); $unbox_configuration = function () { $container = (require __DIR__ . '/bootstrap-unbox.php'); }; $bench->add('configuration', $unbox_configuration); foreach (array(1, 10) as $num) { $bench->add("{$num} repeated resolutions", function () use($num) { $container = (require __DIR__ . '/bootstrap-unbox.php'); for ($i = 0; $i < $num; $i++) { $cache = $container->get(UserRepository::class); } }, $unbox_configuration); } $bench->run();