473,399 Members | 3,038 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Comments, do they technicaly slow php down?

Hi,

I proud myself in having good comments, (/**/, // etc...), all over my
scripts as well as a very descriptive section at the beginning of the
script.
No correct me if i am wrong but php must still 'read' those comments?

So, do comments technically slow the whole process?
Or is the loss of CPU/Time/memory so negligible that i do not need to worry
about it.

Simon.
Jul 17 '05 #1
4 3363
"Sims" <si*********@hotmail.com> wrote in message
news:c1*************@ID-162430.news.uni-berlin.de...
Hi,

I proud myself in having good comments, (/**/, // etc...), all over my
scripts as well as a very descriptive section at the beginning of the
script.
No correct me if i am wrong but php must still 'read' those comments?

So, do comments technically slow the whole process?
Or is the loss of CPU/Time/memory so negligible that i do not need to worry about it.

Simon.


For the most part, I would say do not worry about it.

But, if you must, you can do this from the command line

php -w scriptname.php > newname.php

this will strip out all comments, whitespaces.

you can then run your script again, and see if there is a difference.

--
Mike Bradley
http://www.gzentools.com -- free online php tools
Jul 17 '05 #2
On Sun, 29 Feb 2004 10:20:17 +0200, "Sims" <si*********@hotmail.com> wrote:
I proud myself in having good comments, (/**/, // etc...), all over my
scripts as well as a very descriptive section at the beginning of the
script.
No correct me if i am wrong but php must still 'read' those comments?

So, do comments technically slow the whole process?
Or is the loss of CPU/Time/memory so negligible that i do not need to worry
about it.


I really would not worry about it. It makes the file slightly larger, but
those comments are very valuable, and it's easy for the parser to skip them
anyway.

Just tried an artificial scenario with one file having just an echo, and the
other file having the same echo but 20k of comments. Came out with this:

Benchmark: timing 500 iterations of comments, nocomments...
comments: 43 wallclock secs ( 0.24 usr + 0.84 sys = 1.08 CPU) @ 462.53/s
(n=500)
nocomments: 43 wallclock secs ( 0.29 usr + 0.63 sys = 0.92 CPU) @ 542.89/s
(n=500)

So the difference isn't exactly earth-shattering, and that's with about a
1500:1 comment-to-code ratio. Odds are you'll could make peformance increases
orders of magnitude greater by improving the algorithms in your code rather
than worrying about microseconds potentially saved by not having comments.

--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
<http://www.andyh.co.uk> / <http://www.andyhsoftware.co.uk/space>
Jul 17 '05 #3

I really would not worry about it. It makes the file slightly larger, but
those comments are very valuable, and it's easy for the parser to skip them anyway.

Just tried an artificial scenario with one file having just an echo, and the other file having the same echo but 20k of comments. Came out with this:

Benchmark: timing 500 iterations of comments, nocomments...
comments: 43 wallclock secs ( 0.24 usr + 0.84 sys = 1.08 CPU) @ 462.53/s (n=500)
nocomments: 43 wallclock secs ( 0.29 usr + 0.63 sys = 0.92 CPU) @ 542.89/s (n=500)

So the difference isn't exactly earth-shattering, and that's with about a
1500:1 comment-to-code ratio. Odds are you'll could make peformance increases orders of magnitude greater by improving the algorithms in your code rather than worrying about microseconds potentially saved by not having comments.


Thanks both for the replies,

I am just trying to 'clean' my code and i am looking at best ways of doing
that.
I am starting to think i need something to run some test for me,

Is there a way to runs stats per page?

Like CPU time. php.exe time, DB time etc and maybe more?
Those would be really helpful to give my boss a really professional looking
site.

Many thanks

Sims
Jul 17 '05 #4
In message <c1*************@ID-162430.news.uni-berlin.de>, Sims
<si*********@hotmail.com> writes

I really would not worry about it. It makes the file slightly larger, but
those comments are very valuable, and it's easy for the parser to skipthem
anyway.

Just tried an artificial scenario with one file having just an echo, and

the
other file having the same echo but 20k of comments. Came out with this:

Benchmark: timing 500 iterations of comments, nocomments...
comments: 43 wallclock secs ( 0.24 usr + 0.84 sys = 1.08 CPU) @

462.53/s
(n=500)
nocomments: 43 wallclock secs ( 0.29 usr + 0.63 sys = 0.92 CPU) @

542.89/s
(n=500)

So the difference isn't exactly earth-shattering, and that's with about a
1500:1 comment-to-code ratio. Odds are you'll could make peformance

increases
orders of magnitude greater by improving the algorithms in your code

rather
than worrying about microseconds potentially saved by not having comments.


Thanks both for the replies,

I am just trying to 'clean' my code and i am looking at best ways of doing
that.


When I come to have to do something to a program someone else has
written, I start by fixing the layout, indentation & comments. I would
not dream of getting rid of comments in the hope it will run a fraction
faster, or produce an 'object' (in the broadest sense) that's a fraction
smaller. IMHO machines are so powerful compared with even a few years
back that what I need to do is concentrate on the functionality and the
elegance of the coding, not the smallness and obscurity of it.

(however I do get rid of 'and now for the clever bit' kind of comments!)

I am starting to think i need something to run some test for me,

Is there a way to runs stats per page?

Like CPU time. php.exe time, DB time etc and maybe more?
Those would be really helpful to give my boss a really professional looking
site.

Many thanks

Sims


--
Five Cats
Email to: cats_spam at uk2 dot net
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: lkrubner | last post by:
I've got a PHP application that's 2 megs in size. Of that, my guess is 200k-400k is comments. Do they impose a performance hit? I've been postponing any kind of optimization, but at some point I'll...
12
by: windandwaves | last post by:
Hi Folks I have just completed a project for an accommodation finder in New Zealand - much with your help - thank you again. I would appreciate any constructive or deconstructive comments. ...
14
by: Jim Hubbard | last post by:
http://www.eweek.com/article2/0,1759,1774642,00.asp
5
by: Michael Turner | last post by:
Hi Guys I am currently working on a project and it is constantly being updated, when I change code I normall comment out the old line(s) and then retype my new code, just incase I need to revert...
0
by: Travis Oliphant | last post by:
This post is to gather feedback from the wider community on PEP 357. It is nearing the acceptance stage and has previously been discussed on python-dev. This is a chance for the wider Python...
98
by: tjb | last post by:
I often see code like this: /// <summary> /// Removes a node. /// </summary> /// <param name="node">The node to remove.</param> public void RemoveNode(Node node) { <...> }
5
by: howa | last post by:
will performance increae if I removed comments & space from source code using php -w ...? given that i don't need to modify the source code, & don't use any cache?
21
by: Galen Somerville | last post by:
My application receives and displays Heart sounds and ECG's in real time. This data comes from a proprietary USB 2.0 device. Unlike most USB devices, this data comes in short bursts of about 24...
10
by: penworthamnaynesh | last post by:
Does php slow your website down? This is what i would like to know.The reason is because my site is writtent 50% in html and 50% in php and is very slow at loading. And i cant tell wether php is...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.