473,320 Members | 1,876 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,320 software developers and data experts.

Is it useful to remove comments & spaces from source code?

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?

Jan 30 '07 #1
5 6804
howa wrote:
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?
Hi

php -w will return the stripped sourcecode (whitespace and comment).
It will not run the script.

If you reduce your filesize by removing comments, you will get:
1) a slightly faster execution (don't expect too much).
2) A headache if you want to modify the code and the usefull comments are
stripped out.

My advise: Don't do it.

If your application is slow, find out why. I am quite sure it is NOT the
commentlines that makes the application slow.

Just do some simple profiling, using microtime() to store the time for each
thing that happens in your script.
In my experience, 9 out of 10 times the reason for slow webapps is a poorly
designed database, or poorly designed query logic.
for example: running 40 seperate queries to build 1 page.

Regards,
Erwin Moller
Jan 30 '07 #2
we will keep an original codes in the SVN,...

the main point is: around 20-30% of file size are from comments &
white space, we think that when each time include_once is called,
dummy information need to be read by PHP interpreter, seems waste of
cpu time...
My advise: Don't do it.

If your application is slow, find out why. I am quite sure it is NOT the
commentlines that makes the application slow.

Just do some simple profiling, using microtime() to store the time for each
thing that happens in your script.
In my experience, 9 out of 10 times the reason for slow webapps is a poorly
designed database, or poorly designed query logic.
for example: running 40 seperate queries to build 1 page.

Regards,
Erwin Moller

Jan 30 '07 #3
howa wrote:
we will keep an original codes in the SVN,...

the main point is: around 20-30% of file size are from comments &
white space, we think that when each time include_once is called,
dummy information need to be read by PHP interpreter, seems waste of
cpu time...
Well, simply benchmark the execution time with and without comments.

But I don't think you will see a large increase in performance.
The IO needed to read a few K comments will not be impressive...

Remember that every modern OS caches files on disk in memory, even reducing
that overhead..

If your app is slow, find out why first, or you'll be wasting your time
shooting in the dark.

Regards,
Erwin Moller
>

>My advise: Don't do it.

If your application is slow, find out why. I am quite sure it is NOT the
commentlines that makes the application slow.

Just do some simple profiling, using microtime() to store the time for
each thing that happens in your script.
In my experience, 9 out of 10 times the reason for slow webapps is a
poorly designed database, or poorly designed query logic.
for example: running 40 seperate queries to build 1 page.

Regards,
Erwin Moller
Jan 30 '07 #4

"howa" <ho******@gmail.comwrote in message
news:11*********************@m58g2000cwm.googlegro ups.com...
we will keep an original codes in the SVN,...

the main point is: around 20-30% of file size are from comments &
white space, we think that when each time include_once is called,
dummy information need to be read by PHP interpreter, seems waste of
cpu time...

CPU time is cheap. Developer time is expensive. Work it out.
Jan 30 '07 #5
..oO(howa)
>the main point is: around 20-30% of file size are from comments &
white space, we think that when each time include_once is called,
dummy information need to be read by PHP interpreter, seems waste of
cpu time...
The real bottlenecks are somewhere else. The xdebug extension contains a
profiler, which can show you where you're really wasting CPU time. It's
in your code, not the comments.

Micha
Jan 30 '07 #6

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

Similar topics

16
by: Franz Steinhaeusler | last post by:
Hi, I looked at tabnanny to check a python source file. But I didn't find anything, tabnanny is able to find, what couldn't be found by compile command. Or have I missed something? best...
6
by: qwweeeit | last post by:
For a python code I am writing I need to remove all strings definitions from source and substitute them with a place-holder. To make clearer: line 45 sVar="this is the string assigned to sVar"...
32
by: Elliot Temple | last post by:
Hi I have two questions. Could someone explain to me why Python is case sensitive? I find that annoying. Also, why aren't there multiline comments? Would adding them cause a problem of some...
13
by: rbronson1976 | last post by:
Hi all, I have a very simple page that Firefox has problems with: www.absolutejava.com/testing.htm First of all, this page seems to be perfectly valid XHTML Strict. Both the W3C validator as...
1
by: Arjen | last post by:
Hello, In code view I use a tab as mark-up character. When I run my web application I can see the tabs with the source viewer in my browser. Is there a way to remove the tabs, extra spaces...
25
by: mdh | last post by:
Hi Group, Not looking for an answer, but more of an explanation. Thinking back to those heady days when you had the time to do them, may I ask this. Exercise 1-22 asks for a program to "fold"...
3
by: VK | last post by:
If it was already answered somewhere, I'll be glad to be pointed to (after the necessary comments on my search abilities :-) I need as booletproof as possible way to strip out whitespaces from...
17
by: Andrew C. | last post by:
I'm trying to complete excercise 1-23 in the K&R book, which calls for a program to wrap input lines at a given column, making sure to handle lines that wrap twice or don't contain whitespace. This...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.