Someone extremely smart at work told me try catches which don’t throw will affect performance on a site with millions of users. based on the unit test posted showing equal performance, I’m wondering if this is related to an os level and/or web server specific situation. For instance, web server’s implementation of asynchronous work occurs on child processes instead of threads.
Anyone know?
What I’d like to see is an output of a php profiler showing actual cpu time used.
jmucchiello’s comment on Performance of try-catch in php is interesting, but doesn’t measure cpu time used.
Thanks,
David
I ran a very small and unscientific test and found there to be roughly no difference between having a catch that never gets called or having it outside a try catch statement. I ran each of these two scripts 5 times each through my profiler and averaged the total times.
Results
The Code
Try/Catch
No Try/Catch