Skip to content

Instantly share code, notes, and snippets.

@PJK
Created April 27, 2011 11:41
Show Gist options
  • Save PJK/944108 to your computer and use it in GitHub Desktop.
Save PJK/944108 to your computer and use it in GitHub Desktop.
Reference caching test
<?php
require("class.php");
$cache = $a->a->a;
for ($i=1; $i<=$loopcount; $i++) {
$cache->a;
}
<?php
class A {
public $prop;
}
$a = new A;
$a->a = new A;
$a->a->a = new A;
$a->a->a->a = "Ahoooj";
$loopcount = 10e6;
<?php
require("class.php");
for ($i=1; $i<=$loopcount; $i++) {
$a->a->a->a;
}
$ time php -f direct.php
real 0m3.634s
user 0m3.640s
sys 0m0.000s
$ time php -f cache.php
real 0m2.037s
user 0m2.020s
sys 0m0.020s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment