Beispiel #1
0
 public function configure(Container $container)
 {
     $container->register('xdebug.command.profile', function (Container $container) {
         return new ProfileCommand($container->get('console.command.handler.runner'));
     }, array('console.command' => array()));
     $container->register('benchmark.executor.xdebug', function (Container $container) {
         return new XDebugExecutor($container->get('benchmark.remote.launcher'));
     }, array('benchmark_executor' => array('name' => 'xdebug')));
 }
 public function initUnoptimized()
 {
     $container = new Container();
     $container->register('bicycle_factory', function ($c) {
         return new \PhpBench\Benchmarks\Container\Acme\BicycleFactory();
     });
     $this->container = $container;
 }
Beispiel #3
0
 public function load(Container $container)
 {
     if (!class_exists(Version::class)) {
         throw new \RuntimeException('The DBAL extension requires the "doctrine/dbal" package. Run `composer require --dev "doctrine/dbal"`');
     }
     $container->register('storage.driver.dbal.connection', function (Container $container) {
         static $connection;
         if ($connection) {
             return $connection;
         }
         $params = $container->getParameter('storage.dbal.connection');
         if (isset($params['path'])) {
             $params['path'] = PhpBench::normalizePath($params['path']);
         }
         $connection = DriverManager::getConnection($params);
         return $connection;
     });
     $container->register('storage.driver.dbal.connection_manager', function (Container $container) {
         return new Storage\Driver\Dbal\ConnectionManager($container->get('storage.driver.dbal.connection'));
     });
     $container->register('storage.driver.dbal', function (Container $container) {
         return new Storage\Driver\DbalDriver($container->get('storage.driver.dbal.loader'), $container->get('storage.driver.dbal.persister'), $container->get('storage.driver.dbal.repository'));
     }, ['storage_driver' => ['name' => 'dbal']]);
     $container->register('storage.driver.dbal.persister', function (Container $container) {
         return new Storage\Driver\Dbal\Persister($container->get('storage.driver.dbal.connection_manager'));
     });
     $container->register('storage.driver.dbal.loader', function (Container $container) {
         return new Storage\Driver\Dbal\Loader($container->get('storage.driver.dbal.repository'));
     });
     $container->register('storage.driver.dbal.visitor.token_value', function (Container $container) {
         return new Storage\Driver\Dbal\Visitor\TokenValueVisitor($container->get('storage.uuid_resolver'));
     });
     $container->register('storage.driver.dbal.repository', function (Container $container) {
         return new Storage\Driver\Dbal\Repository($container->get('storage.driver.dbal.connection_manager'), $container->get('storage.driver.dbal.visitor.token_value'));
     });
     $container->register('command.dbal.migrate', function (Container $container) {
         return new MigrateCommand($container->get('storage.driver.dbal.connection'));
     }, ['console.command' => []]);
 }
Beispiel #4
0
 public function load(Container $container)
 {
     $container->register('xdebug.command.profile', function (Container $container) {
         return new ProfileCommand($container->get('console.command.handler.runner'), $container->get('xdebug.command.handler.output_dir'));
     }, ['console.command' => []]);
     $container->register('xdebug.command.trace', function (Container $container) {
         return new TraceCommand($container->get('console.command.handler.runner'), $container->get('xdebug.renderer.trace'), $container->get('xdebug.command.handler.output_dir'));
     }, ['console.command' => []]);
     $container->register('xdebug.command.handler.output_dir', function (Container $container) {
         return new OutputDirHandler($container->getParameter('xdebug.output_dir'));
     });
     $container->register('benchmark.executor.xdebug_profile', function (Container $container) {
         return new ProfileExecutor($container->get('benchmark.remote.launcher'));
     }, ['benchmark_executor' => ['name' => 'xdebug_profile']]);
     $container->register('xdebug.executor.xdebug_trace', function (Container $container) {
         return new TraceExecutor($container->get('benchmark.remote.launcher'));
     }, ['benchmark_executor' => ['name' => 'xdebug_trace']]);
     $container->register('xdebug.renderer.trace', function (Container $container) {
         return new TraceRenderer($container->get('phpbench.formatter'));
     });
     $container->mergeParameter('executors', require_once __DIR__ . '/config/executors.php');
     $container->mergeParameter('reports', require_once __DIR__ . '/config/generators.php');
 }
Beispiel #5
0
 private function registerRegistries(Container $container)
 {
     foreach (array('generator', 'renderer') as $registryType) {
         $container->register('report.registry.' . $registryType, function (Container $container) use($registryType) {
             return new Registry($registryType, $container, $container->get('json_schema.validator'));
         });
     }
     $container->register('benchmark.registry.executor', function (Container $container) {
         return new Registry('executor', $container, $container->get('json_schema.validator'));
     });
 }
Beispiel #6
0
 public function load(Container $container)
 {
     $container->register('foobar', function ($container) {
         $stdClass = new \stdClass();
         $stdClass->foobar = $container->getParameter('foo');
         return $stdClass;
     });
 }
Beispiel #7
0
 private function registerExpression(Container $container)
 {
     $container->register('expression.parser', function (Container $container) {
         return new Parser();
     });
 }
Beispiel #8
0
 private function registerTabular(Container $container)
 {
     $container->register('tabular.xpath_resolver', function () {
         require_once __DIR__ . '/../Dom/xpath_functions.php';
         $resolver = new XPathResolver();
         $resolver->registerFunction('parameters_to_json', 'PhpBench\\Dom\\functions\\parameters_to_json');
         $resolver->registerFunction('class_name', 'PhpBench\\Dom\\functions\\class_name');
         $resolver->registerFunction('join_node_values', 'PhpBench\\Dom\\functions\\join_node_values');
         $resolver->registerFunction('suite', 'PhpBench\\Dom\\functions\\suite');
         return $resolver;
     });
     $container->register('tabular.table_builder', function (Container $container) {
         return new TableBuilder($container->get('tabular.xpath_resolver'));
     });
     $container->register('tabular.formatter.registry', function (Container $container) {
         $registry = new ArrayRegistry();
         $registry->register('printf', new PrintfFormat());
         $registry->register('balance', new BalanceFormat());
         $registry->register('number', new NumberFormat());
         $registry->register('truncate', new TruncateFormat());
         $registry->register('json_format', new JSONFormat());
         $registry->register('time', new TimeFormat());
         return $registry;
     });
     $container->register('tabular.formatter', function (Container $container) {
         return new Formatter($container->get('tabular.formatter.registry'));
     });
     $container->register('tabular', function (Container $container) {
         return new Tabular($container->get('tabular.table_builder'), $container->get('tabular.definition_loader'), $container->get('tabular.formatter'), $container->get('tabular.expander'));
     });
     $container->register('tabular.definition_loader', function (Container $container) {
         return new Loader($container->get('json_schema.validator'));
     });
     $container->register('tabular.expander', function (Container $container) {
         return new Expander();
     });
 }
Beispiel #9
0
 public function registerEnvironment(Container $container)
 {
     $container->register('environment.provider.uname', function (Container $container) {
         return new Provider\Uname();
     }, array('environment_provider' => array()));
     $container->register('environment.provider.php', function (Container $container) {
         return new Provider\Php();
     }, array('environment_provider' => array()));
     $container->register('environment.provider.unix_sysload', function (Container $container) {
         return new Provider\UnixSysload();
     }, array('environment_provider' => array()));
     $container->register('environment.provider.git', function (Container $container) {
         return new Provider\Git();
     }, array('environment_provider' => array()));
     $container->register('environment.supplier', function (Container $container) {
         return new Supplier();
     });
 }