Reply
Removing a script comments for faster performance?
Old 03-09-2010, 04:45 PM Removing a script comments for faster performance?
etrader's Avatar
Experienced Talker

Posts: 30
Trades: 0
Since php scripts (like CMSs) are written for a general audience, they have lots of comments between */ */ tags to explain what the php codes do this. Obviously this increases the sizes of the php files.

I'm just curious whether the presence of such comments affect the load of files? I mean removing the unnecessary comments will make the php files lighters (lesser size); does this have a significant influence on the script performance when reading the php files?
__________________
FatCow Web Hosting
etrader is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 03-09-2010, 05:15 PM Re: Removing a script comments for faster performance?
chrishirst's Avatar
Super Moderator

Posts: 31,017
Location: Blackpool. UK
Trades: 0
No.

lines inside comment blocks /* ... */ are simply skipped by the interpreter as it goes into "read ahead" on the open delimiter until it encounter the end delimiter.

lines with "//" in are processed to the comment marker and anything after the marker is discarded.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Code Samples | Crowded Nightclub? | Random Ramblings
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-10-2010, 07:42 AM Re: Removing a script comments for faster performance?
etrader's Avatar
Experienced Talker

Posts: 30
Trades: 0
Quote:
Originally Posted by chrishirst View Post
No.

lines inside comment blocks /* ... */ are simply skipped by the interpreter as it goes into "read ahead" on the open delimiter until it encounter the end delimiter.

lines with "//" in are processed to the comment marker and anything after the marker is discarded.
But it should have an influence on the CPU usage, as the system should open the whole file; like opening a large file in windows.
__________________
FatCow Web Hosting
etrader is offline
Reply With Quote
View Public Profile
 
Old 03-10-2010, 08:29 AM Re: Removing a script comments for faster performance?
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,078
Trades: 1
i didnt think it opened the whole file?
I thought it streamed it..
lynxus is offline
Reply With Quote
View Public Profile Visit lynxus's homepage!
 
Old 03-10-2010, 08:34 AM Re: Removing a script comments for faster performance?
tripy's Avatar
Do not try this at home!

Posts: 3,600
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Quote:
But it should have an influence on the CPU usage, as the system should open the whole file; like opening a large file in windows.
And what do you think the PHP engine does on each access to a PHP file ?
Php is a dynamic, scripting language. As it is not compiled in a binary form, each access to it cause the parsing of the file.
Of course it have an incidence, but the comment are so light, that they are negligible.

Last time I did a trace into PHP files, 98% of the execution time where sending SQL query to the db and waiting for the result.
Optimize your code logic first, then your sql queries, and don't bother going further.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 03-10-2010, 10:04 AM Re: Removing a script comments for faster performance?
wayfarer07's Avatar
Eat You

Posts: 3,570
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Quote:
Originally Posted by tripy View Post
Last time I did a trace into PHP files, 98% of the execution time where sending SQL query to the db and waiting for the result.
Is that typical, or is it just the last time you did the test?
__________________
Wayfarer | bBoard
If Google is the Coca-Cola of Web search, Bing is RC Cola
wayfarer07 is online now
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 03-10-2010, 10:29 AM Re: Removing a script comments for faster performance?
tripy's Avatar
Do not try this at home!

Posts: 3,600
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Well, the db operations where heavy in that specific page.
The typical time I saw on more conventional pages is around 60~70%.

Significantly less, but still a lot.
At the time, I used Xdebug and KCacheGrind on linux to visualize the trace.
You can use wincachegrind on windows for that too: http://sourceforge.net/projects/wincachegrind/

http://xdebug.org/docs/profiler
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to Removing a script comments for faster performance?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.10912 seconds with 13 queries