Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance issue #12

Closed
alexislefebvre opened this issue Jun 5, 2019 · 12 comments
Closed

Performance issue #12

alexislefebvre opened this issue Jun 5, 2019 · 12 comments
Labels
bug Something isn't working

Comments

@alexislefebvre
Copy link
Collaborator

alexislefebvre commented Jun 5, 2019

Preconditions

Performance issue with version 1.0 of this bundle: liip/LiipFunctionalTestBundle#516 (comment) compared to LiipFunctionalTestBundle 2.0.0-alpha16

Steps to reproduce

.

Expected result

.

Actual result

Tests are about 2x slower.

@alexislefebvre
Copy link
Collaborator Author

@Simperfit found that createSchema is taking much more time.

@alexislefebvre
Copy link
Collaborator Author

TODO : use Blackfire to compare performance with https://github.com/liip/LiipFunctionalTestBundle/releases/tag/2.0.0-alpha16 and LiipFunctionalTestBundle 3.0 and LiipTestFixturesBundle 1.0.

@alexislefebvre
Copy link
Collaborator Author

On a personal project, tests are 4 times slower. 🤔

@alexislefebvre
Copy link
Collaborator Author

TODO: compare when using dependency injection as in #18.

@magnetik
Copy link
Contributor

magnetik commented Aug 5, 2019

Could this be because kernel & containers are not shared between the two bundle so when using both loadFixtures() and makeClient() two kernels are being built?

@alexislefebvre
Copy link
Collaborator Author

@magnetik to my knowledge, event if some code is shared between the 2 bundles, there will be only one instance of the test class so there will be only one kernel built?

@magnetik
Copy link
Contributor

magnetik commented Aug 5, 2019

When using both bundles, the two kernel built are from :

  • \Liip\FunctionalTestBundle\Test\WebTestCase::makeClient through \Symfony\Bundle\FrameworkBundle\Test\WebTestCase::createClient
  • \Liip\TestFixturesBundle\Test\FixturesTrait::loadFixtures (via \Liip\TestFixturesBundle\Test\FixturesTrait::getContainer)

Am I missing something?

@biozshock
Copy link

I found out why in our project we had a slowdown of about 3x.

According to the

->booleanNode('keep_database_and_schema')->defaultFalse()->end()
setting you always recreate schema for the database
if (false === $this->getKeepDatabaseAndSchemaParameter()) {
.

In LiipFunctionalTestBundle v1.x you had that only when sqlite database was defined for tests https://github.com/liip/LiipFunctionalTestBundle/blob/1.x/Test/WebTestCase.php#L449 .

In our case with the tests with MySQL (mysql, percona and mariadb) we had tests passing faster than it was with LiipFunctionalTestBundle 1.x

@alexislefebvre
Copy link
Collaborator Author

Thanks for the investigation @biozshock

The first change to this code was in this PR: https://github.com/liip/LiipFunctionalTestBundle/pull/398/files#diff-3216cb8554ab63f3b7b8531ebcee5156L387

I'll continue to look at changes later.

@alexislefebvre
Copy link
Collaborator Author

We could add a note in the documentation that there are several options to create database and schema:

If the schema doesn't change between tests:

  1. define keep_database_and_schema: true
  2. create database with bin/console --env=test doctrine:database:create:
  3. create schema with php app/console --env=test doctrine:schema:update --force or php app/console --env=test doctrine:migrations:migrate --no-interaction
  4. run PHPUnit

If the schema change between tests:

  1. don't define keep_database_and_schema: true
  2. run PHPUnit and database and schema will be created automatically, please note that this method is slower

@alexislefebvre
Copy link
Collaborator Author

We could add a note in the documentation that there are several options to create database and schema:

Fixed in #120.

The performance issue should be fixed in the 2.x release.

@Dekrikh
Copy link

Dekrikh commented Nov 30, 2023

Performance with LiipTestFixturesBundle v2.6.0

I am experiencing significant performance issues with LiipTestFixturesBundle version 2.6.0 when using the loadFixtures method with zero insertions. Even with an empty set of fixtures as shown below, tests take 7 to 9 seconds to run, which seems abnormally high. And without loadFixtures() 260 ms

$this->databaseTool->loadFixtures([ ExempleFixtures::class]);

 <?php

namespace App\DataFixtures;

use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;

class ExempleFixtures extends Fixture
{
    public function load(ObjectManager $manager)
    {

    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants