Exemplo n.º 1
0
 *
 * 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.3: object with public properties');
$config->setSamples(10);
$config->setReference(3);
$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__ . '/public_user.yml');
    $probe->close();
    $progressBar->advance();
}
$blackfire->endProbe($probe);
$output->success('Finished!');
Exemplo n.º 2
0
 *
 * 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();
}
$blackfire->endProbe($probe);
$output->success('Finished!');
Exemplo n.º 3
0
 *
 * 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.2: mutable object');
$config->setSamples(10);
$config->setReference(2);
$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__ . '/mutable_user.yml');
    $probe->close();
    $progressBar->advance();
}
$blackfire->endProbe($probe);
$output->success('Finished!');
Exemplo n.º 4
0
 *
 * 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 3');
$config->setSamples(1);
$config->setReference(6);
$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__ . '/fixtures.yml');
    $probe->close();
    $progressBar->advance();
}
$blackfire->endProbe($probe);
$output->success('Finished!');
Exemplo n.º 5
0
use Faker\Factory;
use Faker\Generator;
use Nelmio\Alice\scenario2\ImmutableUser;
use Nelmio\Alice\scenario2\MutableUser;
use Nelmio\Alice\scenario2\PublicUser;
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 0');
$config->setSamples(10);
$config->setReference(0);
$probe = $blackfire->createProbe($config, false);
$output = new SymfonyStyle(new ArrayInput([]), new ConsoleOutput());
$progressBar = new ProgressBar($output, $config->getSamples());
$faker = Factory::create();
$output->writeln(sprintf('Start profiling of <info>%s</info> with <info>%d samples.</info>', $config->getTitle(), $config->getSamples()));
for ($i = 1; $i <= $config->getSamples(); $i++) {
    $probe->enable();
    script($faker);
    $probe->close();
    $progressBar->advance();
}
$blackfire->endProbe($probe);
$output->success('Finished!');
function script(Generator $faker)
{
Exemplo n.º 6
0
 *
 * 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 2');
$config->setSamples(10);
$config->setReference(5);
$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__ . '/fixtures.yml');
    $probe->close();
    $progressBar->advance();
}
$blackfire->endProbe($probe);
$output->success('Finished!');
Exemplo n.º 7
0
 *
 * 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.4: stdClass object');
$config->setSamples(10);
$config->setReference(4);
$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__ . '/stdClass.yml');
    $probe->close();
    $progressBar->advance();
}
$blackfire->endProbe($probe);
$output->success('Finished!');