[PHP] Re: Performance Comments Question
Rodolfo Andrade wrote: Hi all! I would like to know if comments in the code affects the performance. I know that comments are ignored by the interpreter, but it does increase the file size, so I was thinking about a possible performance hit for highly commented files. Can anyone confirm this? Thanks! Rodolfo Andrade Im not quietly sure how the parser works but i think it stops reading a line for example when the // or # are detected how its about /* and */ im not quitly sure. but i think this commenting will affect the parser in some way. And yes i also think commenting affects the parser. Not much though but well it does. Barry -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Performance Comments Question
Barry wrote: Rodolfo Andrade wrote: Hi all! I would like to know if comments in the code affects the performance. I know that comments are ignored by the interpreter, but it does increase the file size, so I was thinking about a possible performance hit for highly commented files. Can anyone confirm this? Thanks! Rodolfo Andrade Im not quietly sure how the parser works but i think it stops reading a line for example when the // or # are detected how its about /* and */ im not quitly sure. but i think this commenting will affect the parser in some way. the comments are parsed by the parser and can be extracted/used for doc building etc - this means there is some overhead for commented files. if you use an opcode cache then the overhead is only relevant at the time a source file is compiled into opcodes (I don't know any opcode cache that doesn't strip out the comment tokens from the compiled code) in real life you won't notice the overhead at all. and people will love you if you'r files are 90% comments :-) And yes i also think commenting affects the parser. Not much though but well it does. Barry -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Performance Comments Question
On Thu, 19 Jan 2006 14:09:00 +0100 Jochem Maas [EMAIL PROTECTED] wrote: in real life you won't notice the overhead at all. and people will love you if you'r files are 90% comments :-) I've never been quite that liberal with my comments, but I do have a few files that are 50% comments... Regards, Ozz. pgprVbyZK7agN.pgp Description: PGP signature
Re: [PHP] Re: Performance Comments Question
Austin Denyer wrote: On Thu, 19 Jan 2006 14:09:00 +0100 Jochem Maas [EMAIL PROTECTED] wrote: in real life you won't notice the overhead at all. and people will love you if you'r files are 90% comments :-) I've never been quite that liberal with my comments, but I do have a few files that are 50% comments... you should be getting a warm and fuzzy feeling right about now :-) it's not love at first sight but we can work with it ;-) Regards, Ozz. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Performance Comments Question
On Thu, January 19, 2006 7:09 am, Jochem Maas wrote: Barry wrote: Rodolfo Andrade wrote: and people will love you if you'r files are 90% comments :-) Actually, the times I've seen THAT much commenting, it was generally a lot of useless noise and I hated it... Consider this common practice: /** Function: foo Purpose: foo the input string and return a string Inputs: $string, the input string Output: result string of foo Author: Some I. Guy [EMAIL PROTECTED] Date: 4/1/2005 **/ function foo($string){ //code I don't understand return $result; // I got this part :-) } Note: The Author no longer works at Example, and his email address is invalid, of course. If you're going to comment, then comment on the high-level stuff of what you are *DOING*, not the minutia I can read in the source in the first place! Oh yeah: Comments with increased file size certainly matter, depending on the disk block size, the OS cache size, PHP's cache sizes, the number of times you foolishly 'include' them, the number of files you've broken things into, etc... You'd have to have a HELL of a lot of comments for that part to matter. The PHP parser can't be working TOO hard to rip out comments -- It doesn't even allow nested comments /* ... /* ... */ ... */ so it only has to scan ahead for the character combination '*/' and that's pretty fast. If you are using an opcode cache, it becomes even more meaning less, as noted. You could almost for sure find a comment-stripper out there and benchmark for yourself on your own hardware: http://info.com/php+comment+strip -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php