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

In verbose mode, add the execution time of fixtures #445

Open
florentdestremau opened this issue Jun 21, 2024 · 2 comments
Open

In verbose mode, add the execution time of fixtures #445

florentdestremau opened this issue Jun 21, 2024 · 2 comments

Comments

@florentdestremau
Copy link

Hi, I did a local trick to try and optimize our fixtures performance, it's pretty nice to see where you fixture time is going.

image

The trick is as simple as it gets, but I wonder how I could enable this only in verbose mode:

//src/Executor/ORMExecutor.php

    public function execute(array $fixtures, $append = false)
    {
        $executor = $this;
        $this->em->wrapInTransaction(static function (EntityManagerInterface $em) use ($executor, $fixtures, $append) {
            if ($append === false) {
                $executor->purge();
            }

            foreach ($fixtures as $fixture) {
                $start = microtime(true);
                $executor->load($em, $fixture);
                $end = microtime(true);
                $executionTime = $end - $start;
                echo 'Execution Time: ' . $executionTime . PHP_EOL;
            }
        });
    }

My issue here is that it's overlapping the bundle and the library and I don't see any easy hook to catch.

@greg0ire
Copy link
Member

You could instead write a decorator implementing FixtureInterface, then decorate each fixture when gathering them?

@florentdestremau
Copy link
Author

good idea, will dig it. One thing this could have led to is having the total time spent as well (locally I use time bin/console (...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants