Created
June 1, 2009 23:35
-
-
Save tswicegood/121879 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
interface PackageException { } | |
class ConcretePackageException extends Exception implements PackageException { } | |
class MyException extends Exception { } | |
$total_looped = 10000; | |
echo "Throwing three different types of exceptions, ", number_format($total_looped), "\n"; | |
$start = microtime(true); | |
for ($i = 0; $i < $total_looped; ++$i) { | |
try { throw new MyException(); } catch (Exception $e) {} | |
} | |
$time = microtime(true) - $start; | |
echo " MyException: ", $time, "\n", | |
" Time Per: ", ($time / $total_looped), "\n"; | |
$start = microtime(true); | |
for ($i = 0; $i < $total_looped; ++$i) { | |
try { throw new ConcretePackageException(); } catch (Exception $e) {} | |
} | |
$time = microtime(true) - $start; | |
echo "ConcretePackageException: ", $time, "\n", | |
" Time Per: ", ($time / $total_looped), "\n"; | |
$start = microtime(true); | |
for ($i = 0; $i < $total_looped; ++$i) { | |
try { throw new Exception(); } catch (Exception $e) {} | |
} | |
$time = microtime(true) - $start; | |
echo " Exception: ", $time, "\n", | |
" Time Per: ", ($time / $total_looped), "\n"; | |
?> | |
// output from run: | |
Throwing three different types of exceptions, 10,000 | |
MyException: 0.034233093261719 | |
Time Per: 3.4233093261719E-6 | |
ConcretePackageException: 0.033795833587646 | |
Time Per: 3.3795833587646E-6 | |
Exception: 0.030992984771729 | |
Time Per: 3.0992984771729E-6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment