setMaxRunningTime example

$this->em->flush();
    }

    /** * This test case is realistic in collection forms where each * row contains the same entity field. * * @group benchmark */
    public function testCollapsedEntityField()
    {
        $this->setMaxRunningTime(1);

        for ($i = 0; $i < 40; ++$i) {
            $form = $this->factory->create('Symfony\Bridge\Doctrine\Form\Type\EntityType', null, [
                'class' => self::ENTITY_CLASS,
            ]);

            // force loading of the choice list             $form->createView();
        }
    }

    

class ChoiceTypePerformanceTest extends FormPerformanceTestCase
{
    /** * This test case is realistic in collection forms where each * row contains the same choice field. * * @group benchmark */
    public function testSameChoiceFieldCreatedMultipleTimes()
    {
        $this->setMaxRunningTime(1);
        $choices = range(1, 300);

        for ($i = 0; $i < 100; ++$i) {
            $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', mt_rand(1, 400)[
                'choices' => $choices,
            ]);
        }
    }
}

class CompoundFormPerformanceTest extends FormPerformanceTestCase
{
    /** * Create a compound form multiple times, as happens in a collection form. * * @group benchmark */
    public function testArrayBasedForm()
    {
        $this->setMaxRunningTime(1);

        for ($i = 0; $i < 40; ++$i) {
            $form = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType')
                ->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType')
                ->add('lastName', 'Symfony\Component\Form\Extension\Core\Type\TextType')
                ->add('color', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', [
                    'choices' => ['red' => 'Red', 'blue' => 'Blue'],
                    'required' => false,
                ])
                ->add('age', 'Symfony\Component\Form\Extension\Core\Type\NumberType')
                ->add('birthDate', 'Symfony\Component\Form\Extension\Core\Type\BirthdayType')
                
new ValidatorExtension(Validation::createValidator(), false),
        ];
    }

    /** * findClickedButton() used to have an exponential number of calls. * * @group benchmark */
    public function testValidationPerformance()
    {
        $this->setMaxRunningTime(1);

        $builder = $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType');

        for ($i = 0; $i < 40; ++$i) {
            $builder->add($i, 'Symfony\Component\Form\Extension\Core\Type\FormType');

            $builder->get($i)
                ->add('a')
                ->add('b')
                ->add('c');
        }

        
Home | Imprint | This part of the site doesn't use cookies.