Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
See twigphp#4176 (comment) Co-Authored-By: Simon André <[email protected]> ``` # Old Benchmark 1: php bench.php Time (mean ± σ): 1.192 s ± 0.004 s [User: 1.163 s, System: 0.009 s] Range (min … max): 1.186 s … 1.198 s 10 runs # New Benchmark 1: php bench.php Time (mean ± σ): 356.5 ms ± 1.1 ms [User: 342.0 ms, System: 7.6 ms] Range (min … max): 354.6 ms … 358.2 ms 10 runs ``` Using bench.php: ``` <?php require_once __DIR__.'/vendor/autoload.php'; $string = str_repeat("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut a tincidunt turpis. \\App\\Entity\\Product \World \065 App\#{var} \'quoted\' Donec pharetra enim quis erat pharetra, dignissim molestie erat laoreet. Vivamus auctor purus sed lorem vestibulum rhoncus.", 10); $loader = new Twig\Loader\ArrayLoader([ 'index.twig' => <<<EOF {{ "$string" }} EOF , ]); $twig = new Twig\Environment($loader); for ($i = 0; $i < 10000; $i++) { $twig->tokenize(new Twig\Source($twig->getLoader()->getSourceContext('index.twig')->getCode(), 'index.twig')); } ```
- Loading branch information