PHPLib Integrated Template 4.13s (100.00%)
PHPLib Template 4.77s (115.58%)
XTemplate 8.94s (216.73%)
FastTemplate 9.78s (237.08%)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<pre>
<?php
//
// README
//
// Bitte FastTemplate etwas streicheln, Win32 Flag ist in der Klasse gesetzt
//
// README
//
// Einfache Funktion zur Zeitmessung
function getmicrotime(){
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
return ($mtime);
}
// Daten für die einfache Listendarstellung eines Artikels
$daten = array(
"URL_BESTELLUNG" => "/cart.php?inc=3016",
"URL_DETAIL" => "/detail.php?art=3016",
"BEZEICHNUNG" => "Easy Rider",
"PREIS" => "14.95 DM"
);
// Anzahl der Testläufe pro Templatesystem
define ("RUNS", 18);
// Anzahl der Artikel in einem Block
define ("ARTIKEL", 25);
// Wo liegen die Templates?
define ("TEMPLATE_ROOT", "c:/www/apache/tpl/");
define ("TEMPLATE_ROOT_FAST", "c:\www\apache");
//
// Test des PHPLib Integrated Template System basierend auf preg_replace()
//
$start = getmicrotime();
for ($i = 0; $i < RUNS; $i++) {
require_once("./integratedtemplate.inc");
// Template laden
$tpl = new IntegratedTemplate();
$tpl->loadTemplatefile(TEMPLATE_ROOT . "template_detail3.html");
// Block auswahlen und parsen
$tpl->setCurrentBlock("product_row");
for ($j = 0; $j < ARTIKEL; $j++) {
$tpl->setVariable($daten);
$tpl->parseCurrentBlock();
}
// Template ggf. parsen und als String zurückliefern
$tpl->get();
}
$time["PHPLib Integrated Template"] = getmicrotime() - $start;
//
// Test des XTemplate System basierend auf ereg_replace()
//
$start = getmicrotime();
for ($i = 0; $i < RUNS; $i++) {
require_once("./xtpl.php");
// Template laden
$tpl = new XTemplate(TEMPLATE_ROOT . "template_detail.html");
// Variablen ersetzen und den Block product_row in main parsen
for ($j = 0; $j < ARTIKEL; $j++) {
$tpl->assign($daten);
$tpl->parse("main.product_row");
}
// main selbst parsen - out greift auf gecachte Werte zu,
// nicht relevant für die Zeitmessung
$tpl->parse("main");
// $tpl->out("main");
}
$time["XTemplate"] = getmicrotime() - $start;
//
// Der alte Liebling: Perl's "Fast" Template mit ereg_replace()
//
$start = getmicrotime();
for ($i = 0; $i < RUNS; $i++) {
require_once("./class.FastTemplate.php3");
$tpl = new FastTemplate(TEMPLATE_ROOT_FAST);
// Template laden
$tpl->define( array("main" => "template_detail2.html") );
$tpl->define_dynamic("product_row", "main");
for ($j = 0; $j < ARTIKEL; $j++) {
$tpl->assign($daten);
$tpl->parse("ROWS", ".product_row");
}
// parsen
$tpl->parse("MAIN", ".main");
// $tpl->FastPrint("MAIN");
}
$time["FastTemplate"] = getmicrotime() - $start;
//
// Der Klassiker: PHPLib Template, hier aus der 7.2b
//
$start = getmicrotime();
for ($i = 0; $i < RUNS; $i++) {
require_once("./template.inc");
$tpl = new Template(TEMPLATE_ROOT);
$tpl->set_file( array("main" => "template_detail3.html") );
$tpl->set_block("main", "product_row", "ROWS");
for ($j = 0; $j < ARTIKEL; $j++) {
$tpl->set_var($daten);
$tpl->parse("ROWS", "product_row", true);
}
$tpl->parse("MAIN", "main");
// $tpl->p("MAIN");
}
$time["PHPLib Template"] = getmicrotime() - $start;
// Laufzeit ausgeben
// Zeit des schnellsten Systems ermitteln
asort($time);
list($class, $t) = each($time);
// Faktor für eine relative Zeitangabe berechnen
$fak = (100 / $t);
// Ausgabe der Ergebnisse
foreach ($time as $class => $t)
printf("%30s %3.2fs (%3.2f%%)\n", $class, $t, $t * $fak);
print "\n\n";
highlight_string(preg_replace("/\t/", " ", implode("", file("c:/www/apache/tpl/index.php", filesize("c:/www/apache/tpl/index.php")))));
print "\n\n";
highlight_string(implode("", file("./template_detail.html", filesize("./template_detail.html"))));
?>
</body>
</html>
<!-- BEGIN: main -->
<table>
<tr>
<td colspan="3">Angebote aus der Artikelgruppe Mustergruppe</td>
</tr>
<!-- BEGIN: product_row -->
<tr>
<td><a href="{URL_BESTELLUNG}"><img src="/cart.gif"></a></td>
<td>{BEZEICHNUNG}, {PREIS}</td>
<td><a href="{URL_DETAIL}">Detailansicht</a></td>
</tr>
<!-- END: product_row -->
</table>
<!-- END: main -->