-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Hello. I recently rewrote my site to another engine and installed Twig 3 there. I found that the render file function with a minimum number of HTML tags and without any attachments or data is rendered for a very long time - 70 ms. While loading Twig itself takes only 14 ms. It is the render function that slows down the site a lot. Tell me where to look for the problem?
nginx, php - 8.4, twig - 3, cache = off, ssd speed 1.5Gb/s
public static function twig($viewDir = null, $getShared = true)
{
$appPaths = new \Config\Paths();
$appViewPaths = $viewDir ?? $appPaths->viewDirectory;
$loader = new \Twig\Loader\FilesystemLoader($appViewPaths);
$twig = new \Twig\Environment($loader, [
'debug' => false,
'cache' => false,
'autoescape' => 'html',
'charset' => 'utf-8',
]);
$twig->addFilter( new \Twig\TwigFilter('is_array', 'is_array') );
return $twig;
}
page.tpl
In the view() function I call twig:
$twig = \Config\Services::twig(); // 14ms
$tpl_data = [];
$template = $twig->render('page.tpl', $tpl_data); // 70ms
If I use insertion into the index.tpl (extends), the time increases to 200ms
The previous project had the same templates and they were loaded in !!! 9ms with insertion into the index.tpl
Previous version of the site - nginx, php 7.4, twig 2.15.5, cache = off