Skip to content

Instantly share code, notes, and snippets.

@nickl-
Created February 6, 2013 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickl-/4724043 to your computer and use it in GitHub Desktop.
Save nickl-/4724043 to your computer and use it in GitHub Desktop.
$ time php compounded.php real 5m18.547s user 0m51.590s sys 0m0.490s
<?php
function foo() { return true; }
function bar() { return true; }
function baz() { return false; }
function bat() { return true; }
function lorem() { return true; }
function ipsum() { return true; }
function dolor() { return false; }
function sit() { return false; }
function amet() { return true; }
function brown() { return true; }
function fox() { static $rep = 0; return ++$rep%2; }
class Lazy {}
class Jumps
{
public $over;
public function dog() {}
}
class Compounded
{
function example() {
if ($this->fooBarLogic())
$this->loremIpsumAndQuickFox();
}
function fooBarLogic() {
return foo() && bar() && (baz() || bat());
}
function loremIpsumAndQuickFox() {
lorem();
ipsum();
if ($this->dolorSitAmetLogic())
$this->postLorem();
}
function postLorem() {
$quick = brown();
$this->jumpsOver();
}
function dolorSitAmetLogic() {
return dolor() || sit() || amet();
}
function jumpsOver() {
$jumps = new Jumps;
while (fox())
$this->lazyDog($jumps);
}
function lazyDog($jumps) {
$jumps->over = new Lazy;
$jumps->dog();
}
}
$comp = new Compounded;
foreach (range(0,1000000) as $i)
$comp->example();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment