473,779 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3378
"Sims" <si*********@ho tmail.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*********@ho tmail.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.andyhsoftwa re.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*********@ho tmail.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
2755
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 have to do it. Is taking out the comments worth it? Of all the optimizations I can do, where should it rank?
12
3518
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. The url is http://switch.hosts.net.nz/~admin64/index.php
14
2272
by: Jim Hubbard | last post by:
http://www.eweek.com/article2/0,1759,1774642,00.asp
5
1147
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 back, I normally clear this down when finished but sometimes it gets left in, I was just wondering if comments in code slow down the performance of the program. Or if the compiler leaves these out. Mike.
0
1374
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 community to comment on the proposal. You will find the PEP attached PEP: 357
98
4626
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
6838
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
1803
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 bytes. These bursts could come as fast as every millisecond. The display of the sound and ECG traces is similar to an oscilloscope display except a blank space of about 5 pixels is shown as it sweeps across the screen. This means that not only is...
10
2361
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 doing it or html o is it another reason because i only have 20gb bandwidth My site is called : ultimate city the game http://www.ultimate-gamez.net
0
9633
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10137
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10074
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9928
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6724
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2867
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.