Results 1 to 12 of 12

Thread: PHP5 slow?

  1. #1

    PHP5 slow?

    hi,

    I was running some stats on php speed this morning, via shell. And it seems to be really slow. I wrote a small script with the following code:

    PHP Code:
    #!/usr/bin/php
    <?php
    for ($i 0$i 100; ++$i) echo("Hello!\n");
    ?>
    I run time ./hello.php and it says:

    real 0m0.463s
    which seems really, really slow.

    By the way a friend tested such a script on his server with php4, and it took 0.036 seconds.

    And in perl on my server it took 0.014 seconds.

    So the speed given seems to be rediculous. Any ideas?

  2. #2
    I think your test is to simple and you didn't have the same conditions for php4. Check this link for more info.
    http://www.sourcelabs.com/SourceLabsPHP4vsPHP5.pdf
    In summary, PHP5 consistently performed better than PHP4. This performance increase varied between being equal in performance to having a performance increase as large as 20.49%. In several test cases, however, PHP4 performed better than PHP5. In one test case testing the function “preg_match” PHP4 performed 29.37% better than PHP5.

  3. #3
    Hi,

    The code executed on the php4 server was exactly the same as what I executed. Regardless, it is rediculous that such a script should take 463 milliseconds to execute. This is not just in one case, I've executed it multiple times and have come out with similar results.

    Let me run it five times right now and give all five results.

    • 0.419
    • 0.768
    • 0.386
    • 0.731
    • 0.235s


    And the server load is 0.14.

  4. #4
    The code was the same but it was on a different machine. You need the same conditions.

    The typical php script has some mysql queries (where it spends 90% of its time) and maybe some regex stuff. The script is used inside apache where the php module is already loaded.

    If you are satisfied with php4, there is no great need to change. I use php5 for my sites and I didn't notice any problem.

  5. #5
    Oh we already use php5, I was just quite disturbed by those stats.

    Brandon

  6. #6
    Try this: (you don't count the loading time for php)

    PHP Code:
    #!/usr/bin/php 
    <?php 
    $start
    =microtime(TRUE);
    for (
    $i 0$i 100; ++$i) echo("Hello!\n"); 
    $end=microtime(TRUE);
    $dif=$end-$start;
    echo 
    "Loop time: $dif\n";
    ?>
    If the server load is 0.14 , you should use your energy on a different issue .

  7. #7
    hi,

    Yeah, with that code it takes about 110 milliseconds.

    Lol, I don't get your comment about the server load?

  8. #8
    Join Date
    Mar 2004
    Location
    New Zealand
    Posts
    533
    Are you testing both PHP4 and PHP5 execution in the same way? Sounds to me like you are testing PHP5 on the cli and PHP4 as an apache module, so of course the PHP5 test would be slower!

  9. #9
    i,

    No, I'm testing php5 as an apache module.

    Anyway I've let this issue go.

  10. #10
    Join Date
    Oct 2004
    Location
    Florida
    Posts
    41
    what they are saying is that the conditions need to be the same , it needs to be the same exact code , running on the same exact server , in the same manner. everything will effect this , versions of apache, server specs , the load the server was under, all of these things need to be factored in.
    ~ PHPConcepts Owner
    ==========================
    http://www.phpconcepts.com

  11. #11
    Join Date
    Jun 2004
    Location
    Bay Area -USA
    Posts
    1,738
    Also if it's a shared server, the server load changes. Maybe you tested it in a time when the load was at a high?
    <<< Please see Forum Guidelines for signature setup. >>>

  12. #12
    hi,

    It may be, I hadn't checked the number of connections at the time. Load was pretty low though, around 0.1.

    I'm not going to worry about it though. A friend ran it on a server with similar specks with php4, and it ran about the same.

Posting Permissions

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