Skip to content

Instantly share code, notes, and snippets.

@jakubkulhan
Created August 4, 2010 20:06
Show Gist options
  • Select an option

  • Save jakubkulhan/508700 to your computer and use it in GitHub Desktop.

Select an option

Save jakubkulhan/508700 to your computer and use it in GitHub Desktop.
<?php
$time = microtime(true);
$i = 0;
loop:
if ($i >= 1000) goto endloop;
$ret = dummy($i);
++$i;
goto loop;
endloop:
echo microtime(true) - $time, "\n";
exit();
function dummy($i)
{
return $i + $i;
}
<?php
$stack = array();
$time = microtime(true);
$i = 0;
loop:
if ($i >= 1000) goto endloop;
array_push($stack, $i);
goto dummy;
L1: $ret = array_pop($stack);
++$i;
goto loop;
endloop:
echo microtime(true) - $time, "\n";
exit();
dummy:
$_i = array_pop($stack);
array_push($stack, $_i * $_i);
goto L1;
<?php
$time = microtime(true);
$i = 0;
loop:
if ($i >= 1000) goto endloop;
goto dummy;
L1: ++$i;
goto loop;
endloop:
echo microtime(true) - $time, "\n";
exit();
dummy:
$ret = $i * $i;
goto L1;
<?php
$time = microtime(true);
$_addr = 1;
$i = 0;
loop:
if ($i >= 1000) goto endloop;
$_0 = 'ret';
$_1 = 'i';
goto dummy;
L1: ++$i;
goto loop;
endloop:
echo microtime(true) - $time, "\n";
exit();
dummy:
$$_0 = $$_1 * $$_1;
goto L1;
<?php
$stack = array();
$stack_sp = -1;
$time = microtime(true);
$i = 0;
loop:
if ($i >= 1000) goto endloop;
$stack[++$stack_sp] = $i;
goto dummy;
L1: $ret = $stack[$stack_sp]; unset($stack[$stack_sp--]);
++$i;
goto loop;
endloop:
echo microtime(true) - $time, "\n";
exit();
dummy:
$_i = $stack[$stack_sp]; unset($stack[$stack_sp--]);
$stack[++$stack_sp] = $_i * $_i;
goto L1;
<?php
$time = microtime(true);
$obj = new Dummy;
$i = 0;
loop:
if ($i >= 1000) goto endloop;
$ret = $obj->dummy($i);
++$i;
goto loop;
endloop:
echo microtime(true) - $time, "\n";
exit();
class Dummy
{
function dummy($i)
{
return $i + $i;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment