[limb-svn] r6375 - in 3.x/trunk/limb/core/tests: . bench

svn at limb-project.com svn at limb-project.com
Thu Oct 4 00:13:11 MSD 2007


Author: pachanga
Date: 2007-10-04 00:13:11 +0400 (Thu, 04 Oct 2007)
New Revision: 6375
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6375

Added:
   3.x/trunk/limb/core/tests/bench/
   3.x/trunk/limb/core/tests/bench/object-attr.php
Log:
-- adding benches for lmbObject attributes access

Added: 3.x/trunk/limb/core/tests/bench/object-attr.php
===================================================================
--- 3.x/trunk/limb/core/tests/bench/object-attr.php	                        (rev 0)
+++ 3.x/trunk/limb/core/tests/bench/object-attr.php	2007-10-03 20:13:11 UTC (rev 6375)
@@ -0,0 +1,49 @@
+<?php
+
+set_include_path(dirname(__FILE__) . '/../../../../');
+require_once('limb/core/common.inc.php');
+require_once('limb/core/src/lmbObject.class.php');
+
+class Foo extends lmbObject
+{
+  function getBar()
+  {
+    return 'bar';
+  }
+}
+$object = new Foo(array('foo' => 'foo'));
+
+$mark = microtime(true);
+
+for($i=0;$i<1000;$i++)
+  $object->get('foo');
+
+echo "raw getter access: " . (microtime(true) - $mark) . "\n";
+
+$mark = microtime(true);
+
+for($i=0;$i<1000;$i++)
+  $object->get('bar');
+
+echo "raw getter access mapped to method: " . (microtime(true) - $mark) . "\n";
+
+$mark = microtime(true);
+
+for($i=0;$i<1000;$i++)
+  $object->getBar();
+
+echo "static getter access: " . (microtime(true) - $mark) . "\n";
+
+$mark = microtime(true);
+
+for($i=0;$i<1000;$i++)
+  $object->getFoo();
+
+echo "dynamic getter access: " . (microtime(true) - $mark) . "\n";
+
+$mark = microtime(true);
+
+for($i=0;$i<1000;$i++)
+  $object->foo;
+
+echo "raw attribute access: " . (microtime(true) - $mark) . "\n";



More information about the limb-svn mailing list