in php i wrote my own debug function which have two arguments: text and a level of message. However i could be also you the php functions for triggering errors. But to debug in development i use sometimes like this:
debug($xmlobject->asXML(),MY_CONSTANT);
now i want to know whether it is a lack of performance in non debug executing because the arguments are calculated indepent whether they will be used inside function? and how to do that right that is only calculated if i need?
Thanks for your help,
Robert
If you write the following portion of code :
Then, no matter what the
debug()function does,$xmlobject->asXML()will be called and executed.If you do not want that expression to be evaluated, you must not call it; I see two possible solutions :
debug()function, not leaving any debugging code in your source files,In the second case, a possibility would be to define a constant to configure whether or not you are in debug-mode, and, then, only call
debug()when needed :Of course, the makes writting debbuging-code a bit harder… and there is a bit of performance-impact (but far smaller than executing the actual code for nothing).