Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class MyException extends Exception{}
- class MyException2 extends Exception{}
- class BusinessLogicError{}
- class Error1 extends BusinessLogicError{}
- class Error2 extends BusinessLogicError{}
- echo microtime(true) . '<br />';
- //7.64
- $i = 1;
- foreach(range(1, 1000000) as $k){
- try{
- throw new MyException2();
- }
- catch(MyException $e){
- $i++;
- }
- catch(MyException2 $e){
- $i++;
- }
- }
- echo microtime(true) . '<br />';
- //1.88 sec
- $i = 0;
- foreach(range(1, 1000000) as $k){
- $result = new Error2;
- if($result === true){
- //ok
- }
- else{
- if($result instanceof Error1){
- $i++;
- }
- elseif($result instanceof Error2){
- $i++;
- }
- }
- }
- echo microtime(true) . '<br />';
- /**
- 1280303418.82
- 1280303426.49
- 1280303429.49
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement