Skip to content

Instantly share code, notes, and snippets.

@c9s
Created April 3, 2016 07:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save c9s/a23cf294dfcf74683b8f02d93a47bc5b to your computer and use it in GitHub Desktop.
Save c9s/a23cf294dfcf74683b8f02d93a47bc5b to your computer and use it in GitHub Desktop.
<?php
require 'vendor/autoload.php';
class User {
public $name;
public function __construct($name) {
$this->name = $name;
}
public function getName()
{
return $this->name;
}
}
$i = 100000;
$startTime = microtime(true);
$loader = new Twig_Loader_Filesystem(realpath('templates'));
$twig = new Twig_Environment($loader, array(
'cache' => realpath('cache'),
));
while ($i--) {
$template = $twig->loadTemplate('index.html');
$template->render(array('users' => [
new User('John'),
new User('Mary'),
new User('Lisa'),
new User('Pedro'),
new User('Jack'),
new User('Chen'),
new User('Lin'),
]));
}
$endTime = microtime(true);
var_dump($endTime - $startTime);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment