Comments, do they technicaly slow php down?

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

    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.


  • CountScubula

    #2
    Re: Comments, do they technicaly slow php down?

    "Sims" <siminfrance@ho tmail.com> wrote in message
    news:c1s7c8$1mb 7l3$1@ID-162430.news.uni-berlin.de...[color=blue]
    > 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[/color]
    worry[color=blue]
    > about it.
    >
    > Simon.
    >
    >
    >[/color]

    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


    Comment

    • Andy Hassall

      #3
      Re: Comments, do they technicaly slow php down?

      On Sun, 29 Feb 2004 10:20:17 +0200, "Sims" <siminfrance@ho tmail.com> wrote:
      [color=blue]
      >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.[/color]

      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 <andy@andyh.co. uk> / Space: disk usage analysis tool
      <http://www.andyh.co.uk > / <http://www.andyhsoftwa re.co.uk/space>

      Comment

      • Sims

        #4
        Re: Comments, do they technicaly slow php down?

        [color=blue]
        >
        > 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[/color]
        them[color=blue]
        > anyway.
        >
        > Just tried an artificial scenario with one file having just an echo, and[/color]
        the[color=blue]
        > 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) @[/color]
        462.53/s[color=blue]
        > (n=500)
        > nocomments: 43 wallclock secs ( 0.29 usr + 0.63 sys = 0.92 CPU) @[/color]
        542.89/s[color=blue]
        > (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[/color]
        increases[color=blue]
        > orders of magnitude greater by improving the algorithms in your code[/color]
        rather[color=blue]
        > than worrying about microseconds potentially saved by not having comments.
        >[/color]

        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


        Comment

        • Five Cats

          #5
          Re: Comments, do they technicaly slow php down?

          In message <c1t9fe$1mrpq6$ 1@ID-162430.news.uni-berlin.de>, Sims
          <siminfrance@ho tmail.com> writes[color=blue]
          >[color=green]
          >>
          >> 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[/color]
          >them[color=green]
          >> anyway.
          >>
          >> Just tried an artificial scenario with one file having just an echo, and[/color]
          >the[color=green]
          >> 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) @[/color]
          >462.53/s[color=green]
          >> (n=500)
          >> nocomments: 43 wallclock secs ( 0.29 usr + 0.63 sys = 0.92 CPU) @[/color]
          >542.89/s[color=green]
          >> (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[/color]
          >increases[color=green]
          >> orders of magnitude greater by improving the algorithms in your code[/color]
          >rather[color=green]
          >> than worrying about microseconds potentially saved by not having comments.
          >>[/color]
          >
          >Thanks both for the replies,
          >
          >I am just trying to 'clean' my code and i am looking at best ways of doing
          >that.[/color]

          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!)

          [color=blue]
          >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
          >
          >[/color]

          --
          Five Cats
          Email to: cats_spam at uk2 dot net

          Comment

          Working...