www.webdeveloper.com
Results 1 to 10 of 10

Thread: Which echo statement causes the server to work harder

  1. #1
    Join Date
    Aug 2004
    Location
    70 klicks above the Do Lung bridge
    Posts
    654

    Which echo statement causes the server to work harder

    PHP Code:
    echo '</p>' "\n"
    or

    PHP Code:
    echo "</p>\n"

  2. #2
    Join Date
    Jul 2003
    Location
    The City of Roses
    Posts
    2,503
    I would guess the first one, but really the difference is so minuscule that it isn't even worth thinking about.
    Last edited by Jeff Mott; 07-23-2008 at 05:35 AM.
    for(split(//,'))*))91:+9.*4:1A1+9,1))2*:..)))2*:31.-1)4131)1))2*:3)"'))
    {for(ord){$i+=$_&7;grep(vec($s,$i++,1)=1,1..($_>>3)-4);}}print"$s\n";

  3. #3
    Join Date
    Aug 2004
    Location
    70 klicks above the Do Lung bridge
    Posts
    654
    Thanks Jeff. Can I just ask what your signature is supposed to do? It looks very intersting.

  4. #4
    Join Date
    Jul 2008
    Posts
    12
    I just tried it, for me the first one was consistently slower by around 0.0005 seconds over 10,000 iterations. You can use this bit of code to quickly benchmark code, run the script a few times to get a consistent time.

    PHP Code:
    <?php
    $start 
    explode(' 'microtime());
    $start $start['1'] + $start['0'];

    $i 0;
    // Change 10000 to the number of times to run the code. The larger the function the less you will likely want to run it.
    while ($i != 10000)
    {
        
    // Code you want to benchmark goes here.
        
    echo "</p>\n";

        ++
    $i;
    }

    $finish explode(' 'microtime());
    $finish $finish['1'] + $finish['0'];

    echo 
    '<p style="margin:auto;text-align:center">'.round(($finish-$start), 6).' seconds</p>';
    ?>

  5. #5
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,321
    Quote Originally Posted by NewsGrail
    I just tried it, for me the first one was consistently slower by around 0.0005 seconds over 10,000 iterations. You can use this bit of code to quickly benchmark code, run the script a few times to get a consistent time....
    Is that 0.0005 seconds per iteration, or per the full 10,000 iterations. If the latter, it's not even worth a second of your time to worry about. If the former (.0005sec/instance) it's still really not worth worrying about unless you're programming some large, intense, high-demand application where every microsecond matters.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  6. #6
    Join Date
    Jul 2008
    Posts
    12
    Over the full 10,000.

  7. #7
    Join Date
    Aug 2004
    Location
    70 klicks above the Do Lung bridge
    Posts
    654
    I thought the difference would be negligable but I just like to be tidy!
    Thanks for the bit of benchmarking code though. It will come in handy!

  8. #8
    Join Date
    Jun 2006
    Location
    Down at the bottom of the garden
    Posts
    1,239
    Quote Originally Posted by NogDog
    Is that 0.0005 seconds per iteration, or per the full 10,000 iterations. If the latter, it's not even worth a second of your time to worry about. If the former (.0005sec/instance) it's still really not worth worrying about unless you're programming some large, intense, high-demand application where every microsecond matters.
    In PHP??!?
    Quote Originally Posted by temp.user123
    You know... You're not so smart. Do you need me to educate you?
    If you say, "please," (and do so, nicely) then I will show you where you're dead wrong.

  9. #9
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,321
    Quote Originally Posted by MrCoder
    In PHP??!?
    Exactly. When microseconds become important, it's probably time to to brush up on your Assembler skills.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  10. #10
    Join Date
    Jun 2006
    Location
    Down at the bottom of the garden
    Posts
    1,239
    Quote Originally Posted by NogDog
    Exactly. When microseconds become important, it's probably time to to brush up on your Assembler skills.
    Or this..
    Quote Originally Posted by temp.user123
    You know... You're not so smart. Do you need me to educate you?
    If you say, "please," (and do so, nicely) then I will show you where you're dead wrong.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles