Symfony批处理请求内核执行时间

I am trying to perform bulk operations using a command line tool and the http_kernel component.

I have stored the requests in a database and, using a command, i'm trying to use my controllers internally by calling $kernel->handle($request); for every request.

The problem is that the execution time of each request is growing up over time.

This command has been run in a test environment and I am sure the execution will be much more faster on the production server.

Edit: I have about 10.000 requests to be executed, and all those requests are very similar

However, I would like to know if there is an optimisation that could be done to ensure a stable execution time for the whole batch.

Here is my code:

$kernel = $this->getContainer()->get('http_kernel');

foreach ($requests as $request) {

        $start = round(microtime(true) * 1000);

        $response = $kernel->handle($request);
        $kernel->terminate($request, $response);

        $requestDuration = (round(microtime(true) * 1000) - $start);

        $output->writeln(($response->isSuccessful() ? ' . ' : ' X ') . '(' . $handleDuration . ')');
}

Here is an example output : (. stands for a successfull request; the time (ms) is in parentheses)

. (246 ms)
. (275 ms)
. (271 ms)
. (268 ms)
. (564 ms)
. (379 ms)
. (353 ms)
. (321 ms)
[...]
. (416 ms)
. (425 ms)
. (409 ms)
. (448 ms)
. (402 ms)
. (405 ms)
. (410 ms)
. (453 ms)
. (476 ms)
. (462 ms)
. (488 ms)
[...]
. (564 ms)
. (537 ms)
. (553 ms)
. (564 ms)
. (510 ms)
. (564 ms)
. (531 ms)
. (569 ms)
. (655 ms)
[...]
. (1155 ms)
. (1179 ms)
. (1142 ms)
. (1126 ms)

Thank you for your help !

(Edit)

Here are some details about the actions performed by the controller :

public function postEntityAction(Request $request) {
    // get the authenticated user
    $authUser = $this->getUser();
    // fetch some data from the database (there is about 6 calls like this one that could be done during the process)
    // note: the hydrator used by all my repository methods is SIMPLEOBJECT
    $item = $itemRepository->getItemById($request->request->get('itemId'));
    // create an entity and set its fields
    $entity = new Entity();
    $entity->setItem($item);
    // I also do some validations using the validator service
    $validator = $this->get('validator');
    $validator->validate($entity);
    // I persist the new entity
    $this->getDoctrine()->getManager()->persist($entity);
    $this->getDoctrine()->getManager()->flush();
    // and finally I return the serialized object (using JMS serializer)
    return $this->serialize($entity);
}