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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • howa

    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?

  • Erwin Moller

    #2
    Re: Is it useful to remove comments & spaces from source code?

    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

    Comment

    • howa

      #3
      Re: Is it useful to remove comments & spaces from source code?

      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

      Comment

      • Erwin Moller

        #4
        Re: Is it useful to remove comments & spaces from source code?

        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

        Comment

        • asdf

          #5
          Re: Is it useful to remove comments & spaces from source code?


          "howa" <howachen@gmail .comwrote in message
          news:1170168271 .039856.63210@m 58g2000cwm.goog legroups.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.


          Comment

          • Michael Fesser

            #6
            Re: Is it useful to remove comments &amp; spaces from source code?

            ..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

            Comment

            Working...