473,396 Members | 1,967 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,396 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 6811
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
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.