Donnerstag, 24. März 2016

Viel Smarty und doch keine Ahnung

Da zieht man eine Sache aus dem Smarty Forum heran als Argument warum man selbst die 1 er Version noch nicht auf Smarty aktuell umgestellt hat.

Da wird bei Smarty eine Sache behandelt mit einem Benchmark der als solches bereits falsch aufgestellt ist und der zudem in der Praxis natürlich  nie vorkommt - aber das ist bei allen Benchmarks der Fall.

Wie dem auch sei - man will mal wieder auf die nächste Smarty Version warten.

Dabei sollte man doch einfach mal einen Benchmark machen der so ausschaut:

<?php
require '../libs/Smarty.class.php';

$smarty = new Smarty();

$loop = 0;
$speed = 50000;

$start = microtime(true);
$smarty->assign("Name", "Fred Irving Johnathan Bradley Peppergill", true);
$smarty->assign("FirstName", array("John", "Mary", "James", "Henry"));
$smarty->assign("LastName", array("Doe", "Smith", "Johnson", "Case"));
$smarty->assign("Class", array(array("A", "B", "C", "D"), array("E", "F", "G", "H"),
                               array("I", "J", "K", "L"), array("M", "N", "O", "P")));

$smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"),
                                  array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")));

$smarty->assign("option_values", array("NY", "NE", "KS", "IA", "OK", "TX"));
$smarty->assign("option_output", array("New York", "Nebraska", "Kansas", "Iowa", "Oklahoma", "Texas"));
$smarty->assign("option_selected", "NE");

for ($i=0; $i<$speed; $i++) {



$smarty->fetch('index.tpl');
$loop++; echo $loop.'<br />';
}

$time = microtime(true) - $start;

echo "Total: " . $time . "<br />";
echo "One: " . ($time/$loop) . "<br />";


Ja richtig . das ist die mitgelieferte Demo etwas verändert.

Die Ergebnisse:


3.29

50000

Total: 20.58358001709
One: 0.0004116716003418


3.27

Versuch 1
20594

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /var/www/html/test1/smarty27/libs/sysplugins/smarty_internal_template.php on line 367


Versuch 2
34326
Fatal error: Maximum execution time of 30 seconds exceeded in /var/www/html/test1/smarty27/libs/sysplugins/smarty_internal_configfileparser.php on line 940

Was nichts weiter bedeutet das die Version 3.27 die bei dem ominösen Benchmark eine Rolle spielt ganz andere Fallen hat und das es ein ziemlicher Unsinn ist so zu argumentieren.

Das Problem - die bei cms...de haben nicht wirklich Ahnung.

Keine Kommentare:

Kommentar veröffentlichen