|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-01-27 14:10 UTC] rasmus@php.net
[2013-01-27 14:10 UTC] rasmus@php.net
-Status: Open
+Status: Wont fix
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 10:00:01 2025 UTC |
Description: ------------ In speed-sensible application this issue might affect the efficiancy. It appears that using an exception to report some error is at least 10 times slower (with recursion of 3) that using old-fashioned function-approach. For test-script below timing for using exception is 2.962 seconds, for using function-approach timing is 0.336 seconds. Test script: --------------- <?php function exceptionf1() { throw new Exception( 'msg' ) ; } function exceptionf2() { exceptionf1() ; } function exceptionf3() { exceptionf2() ; } function returnfunction1( &$error_msg ) { $error_msg = 'msg' ; return false ; } function returnfunction2( &$error_msg ) { return returnfunction1( $error_msg ) ; } function returnfunction3( &$error_msg ) { return returnfunction2( $error_msg ) ; } $t1 = microtime( true ) ; for ( $i = 0 ; $i < 1000000 ; $i++ ) { $success = true ; try { exceptionf3() ; } catch ( Exception $e ) { $success = false ; $error_msg = $e->getMessage() ; } } $d = microtime( true ) - $t1 ; print "d=$d\n" ; $t1 = microtime( true ) ; for ( $i = 0 ; $i < 1000000 ; $i++ ) { $success = returnfunction3( $error_msg ) ; } $d = microtime( true ) - $t1 ; print "d=$d\n" ;