Smarty is one of the oldest template engines for the PHP development language. If you are programming in PHP, likely you have worked with it. A third version of this template was released in 2010. Smarty 3 was written from scratch with the active use of PHP5. At the same time Smarty got an updated syntax and modern features including inheritance, sandbox (computer security) and etc.
Twig is a modern template engine from developers of the Symfony. The authors have positioned it as the fast and functional template. It looks like Smarty 3 a lot in terms of features. Twig features a slightly different syntax, as well as the stated performance. Let us verify it!
We purposely is going to use quite complex templates during testing that the processing time would be noticeable. Actually, we will evaluate this time, so we will prepare the relevant scripts.
Code for Smarty turned out very simple:
$data = json_decode(file_get_contents('data.json'), true);
$smarty = new Smarty();
$smarty->compile_check = false;
$start = microtime(true);