Exemplo n.º 1
0
 *
 * (c) Nelmio <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
declare (strict_types=1);
namespace Nelmio\Alice;

use Nelmio\Alice\Loader\NativeLoader;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Style\SymfonyStyle;
require_once __DIR__ . '/../../vendor-bin/profiling/vendor/autoload.php';
$blackfire = new \Blackfire\Client();
$config = new \Blackfire\Profile\Configuration();
$config->setTitle('Scenario 1.1: immutable object');
$config->setSamples(10);
$config->setReference(1);
$probe = $blackfire->createProbe($config, false);
$output = new SymfonyStyle(new ArrayInput([]), new ConsoleOutput());
$progressBar = new ProgressBar($output, $config->getSamples());
$output->writeln(sprintf('Start profiling of <info>%s</info> with <info>%d samples.</info>', $config->getTitle(), $config->getSamples()));
$loader = new NativeLoader();
for ($i = 1; $i <= $config->getSamples(); $i++) {
    $probe->enable();
    $loader->loadFile(__DIR__ . '/immutable_user.yml');
    $probe->close();
    $progressBar->advance();
}
Exemplo n.º 2
0
require __DIR__ . '/vendor/symfony/symfony/src/Symfony/Component/Routing/RequestContext.php';
//require(__DIR__ . '/vendor/symfony/symfony/src/');
require __DIR__ . '/vendor/symfony/symfony/src/Symfony/Component/Routing/Matcher/RedirectableUrlMatcherInterface.php';
require __DIR__ . '/vendor/symfony/symfony/src/Symfony/Component/Routing/Matcher/RequestMatcherInterface.php';
require __DIR__ . '/vendor/symfony/symfony/src/Symfony/Component/Routing/RequestContextAwareInterface.php';
require __DIR__ . '/vendor/symfony/symfony/src/Symfony/Component/Routing/Matcher/UrlMatcherInterface.php';
require __DIR__ . '/vendor/symfony/symfony/src/Symfony/Component/Routing/Matcher/UrlMatcher.php';
require __DIR__ . '/vendor/symfony/symfony/src/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php';
require __DIR__ . '/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Routing/RedirectableUrlMatcher.php';
require 'original.php';
use Symfony\Component\Routing\RequestContext;
$context = new RequestContext();
$matcher = new appDevUrlMatcher($context);
$withBlackfire = getopt('', ['with-blackfire']) ? true : false;
if ($withBlackfire) {
    $blackfire = new \Blackfire\Client();
    $probe = $blackfire->createProbe();
}
$max = 100000;
$start = microtime(true);
// Best case ==> first route
for ($i = 0; $i < $max; $i++) {
    $matcher->match('/dictionnaire/fr/');
}
echo 'Best case : ' . (microtime(true) - $start) . "\n";
// Middle case
$start = microtime(true);
for ($i = 0; $i < $max; $i++) {
    $matcher->match('/dictionnaire/fr/recherche-top/');
}
echo 'Middle case : ' . (microtime(true) - $start) . "\n";