Skip to content

Instantly share code, notes, and snippets.

@caferrari
Created April 25, 2010 17:38
Show Gist options
  • Save caferrari/378567 to your computer and use it in GitHub Desktop.
Save caferrari/378567 to your computer and use it in GitHub Desktop.
<?php
namespace Teste;
use \ErrorException;
class Test
{
public function metodox(){
}
}
set_error_handler(function ($errno, $errstr, $errfile, $errline ) {
throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
});
$start = 0;
$tick = function($msg='') use (&$start) {
if (!$start) $start = microtime(1);
else{
$t = microtime(1);
$diff = $t - $start;
echo "<br>$msg $diff";
$start = $t;
}
};
$t = new Test();
$ini = microtime(1);
$metodo = array('metodox', 'metodoy');
$tick();
for ($x=0; $x<1000; $x++){
if (!method_exists($t, $metodo[$x%2])) continue;
$t->$metodo[$x%2]();
}
$tick('method_exists');
for ($x=0; $x<1000; $x++){
try{
$t->$metodo[$x%2]();
}catch (Exception $e) { }
}
$tick('try');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment