[limb-svn] r6358 - in 3.x/trunk/limb/macro: src tests/bench tests/bench/tpl

svn at limb-project.com svn at limb-project.com
Tue Oct 2 00:53:43 MSD 2007


Author: pachanga
Date: 2007-10-02 00:53:43 +0400 (Tue, 02 Oct 2007)
New Revision: 6358
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6358

Added:
   3.x/trunk/limb/macro/tests/bench/tpl/wact.html
   3.x/trunk/limb/macro/tests/bench/wact.ini
   3.x/trunk/limb/macro/tests/bench/wact.php
Modified:
   3.x/trunk/limb/macro/src/lmbMacroCodeWriter.class.php
   3.x/trunk/limb/macro/tests/bench/forcecompile.php
   3.x/trunk/limb/macro/tests/bench/native.php
   3.x/trunk/limb/macro/tests/bench/nocompile.php
Log:
-- adding WACT bench
-- some optimizations in lmbMacroCodeWriter


Modified: 3.x/trunk/limb/macro/src/lmbMacroCodeWriter.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroCodeWriter.class.php	2007-10-01 19:57:10 UTC (rev 6357)
+++ 3.x/trunk/limb/macro/src/lmbMacroCodeWriter.class.php	2007-10-01 20:53:43 UTC (rev 6358)
@@ -44,7 +44,7 @@
     $this->registerInclude('limb/macro/src/lmbMacroTemplateExecutor.class.php');
 
     $this->beginMethod($render_func, array('$args = array()'));
-    $this->writePHP('extract($args);');
+    $this->writePHP('if($args) extract($args);');
   }
 
   function getClass()
@@ -118,9 +118,9 @@
     $this->endMethod();
 
     return "<?php\n" .
-           $this->_renderIncludeList() . 
            //protection from self inclusion
            "if(!class_exists('{$this->class}', false)){\n" .
+           $this->_renderIncludeList() . 
            "class {$this->class} " . ($this->parent ? "extends {$this->parent} " : '') . "{\n" .
            $this->_renderMethods() . 
            "\n}" . 

Modified: 3.x/trunk/limb/macro/tests/bench/forcecompile.php
===================================================================
--- 3.x/trunk/limb/macro/tests/bench/forcecompile.php	2007-10-01 19:57:10 UTC (rev 6357)
+++ 3.x/trunk/limb/macro/tests/bench/forcecompile.php	2007-10-01 20:53:43 UTC (rev 6358)
@@ -6,7 +6,7 @@
 
 $config = new lmbMacroConfig('/tmp/macro', true, true, array(dirname(__FILE__) . '/tpl'));
 
-for($i=0;$i<100;$i++)
+for($i=0;$i<1000;$i++)
 {
   $tpl = new lmbMacroTemplate('simple.phtml', $config);
   $tpl->set('name', 'Bob');

Modified: 3.x/trunk/limb/macro/tests/bench/native.php
===================================================================
--- 3.x/trunk/limb/macro/tests/bench/native.php	2007-10-01 19:57:10 UTC (rev 6357)
+++ 3.x/trunk/limb/macro/tests/bench/native.php	2007-10-01 20:53:43 UTC (rev 6358)
@@ -3,7 +3,7 @@
 set_include_path(dirname(__FILE__) . '/../../../../');
 require_once('limb/core/common.inc.php');
 
-for($i=0;$i<100;$i++)
+for($i=0;$i<1000;$i++)
 {
   $name = 'Bob';
   ob_start();

Modified: 3.x/trunk/limb/macro/tests/bench/nocompile.php
===================================================================
--- 3.x/trunk/limb/macro/tests/bench/nocompile.php	2007-10-01 19:57:10 UTC (rev 6357)
+++ 3.x/trunk/limb/macro/tests/bench/nocompile.php	2007-10-01 20:53:43 UTC (rev 6358)
@@ -6,7 +6,7 @@
 
 $config = new lmbMacroConfig('/tmp/macro', false, false, array(dirname(__FILE__) . '/tpl'));
 
-for($i=0;$i<100;$i++)
+for($i=0;$i<1000;$i++)
 {
   $tpl = new lmbMacroTemplate('simple.phtml', $config);
   $tpl->set('name', 'Bob');

Added: 3.x/trunk/limb/macro/tests/bench/tpl/wact.html
===================================================================
--- 3.x/trunk/limb/macro/tests/bench/tpl/wact.html	                        (rev 0)
+++ 3.x/trunk/limb/macro/tests/bench/tpl/wact.html	2007-10-01 20:53:43 UTC (rev 6358)
@@ -0,0 +1 @@
+Hello, {$name}!

Added: 3.x/trunk/limb/macro/tests/bench/wact.ini
===================================================================
--- 3.x/trunk/limb/macro/tests/bench/wact.ini	                        (rev 0)
+++ 3.x/trunk/limb/macro/tests/bench/wact.ini	2007-10-01 20:53:43 UTC (rev 6358)
@@ -0,0 +1,16 @@
+# should template compiler scan for tags, filter and properties every time
+force_scan = 0
+
+# should template compiler recompile templates every time
+force_compile = 0
+
+# absolute path to your wact templates cache dir
+#cache_dir = limb/wact/cache/
+
+# directory where template compiler looks for source templates
+templates_dir = WACT_TPLS
+
+# directories where all compiler looks for tags, filters and properties
+[scan_directories]
+ 0 = limb/wact/src/tags
+

Added: 3.x/trunk/limb/macro/tests/bench/wact.php
===================================================================
--- 3.x/trunk/limb/macro/tests/bench/wact.php	                        (rev 0)
+++ 3.x/trunk/limb/macro/tests/bench/wact.php	2007-10-01 20:53:43 UTC (rev 6358)
@@ -0,0 +1,25 @@
+<?php
+
+set_include_path(dirname(__FILE__) . '/../../../../');
+define('WACT_CACHE_DIR', '/tmp/wact');
+define('WACT_TPLS', dirname(__FILE__) . '/tpl');
+require_once('limb/wact/common.inc.php');
+require_once('limb/wact/src/WactTemplate.class.php');
+require_once('limb/wact/src/WactDefaultTemplateConfig.class.php');
+
+for($i=0;$i<1000;$i++)
+{
+  $tpl = new WactTemplate('wact.html', new WactDefaultTemplateConfig(dirname(__FILE__) . '/wact.ini'));
+  $tpl->set('name', 'Bob');
+  $tpl->capture();
+}
+
+$classes = array();
+foreach(get_declared_classes() as $class)
+{
+    $refl = new ReflectionClass($class);
+      if(strpos($refl->getFileName(), 'src/') !== false)
+            $classes[] = $class;
+}
+sort($classes);
+var_dump($classes);



More information about the limb-svn mailing list