I have a couple of classes that deal with objects, arrays and strings.
I was wondering what the impact on performance is to do type checks like:
is_object(), is_array() and is_string();
I use these quite a lot in my code.
In functions that are being called many thousands of times, is it better to assume the arguments passed is the correct type or check to prevent errors?
Is there any resource where you can have a look at the performance weight of php functions?
You can find out yourself.
Store the current time in milliseconds at the start of your script, run a loop which does a type check several thousand times, and compare the time at the end of your script with the time at the start of your script.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With