SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    my little Perl vs PHP test

    i was curious how much faster PHP as an Apache module was over Perl running through CGI (since that's how most hosts are running them) - to see how much "overhead" there was starting the Perl interpreter, etc. now, this, i don't think, tests the speed of each language, cuz i'm using a very small page, but all i wanted to compare was how many times each version could be loaded in 1 minute. both send exactly the same thing to the browser, which submits a form with an incremented value each time as soon as the page loads.

    this is on Win2k Pro w/ dual 806 PIIIs, Apache 1.3.20, and IE 5.5. PHP version 4.0.6 ("out of the box" php.ini, no Zend Optimizer). ActivePerl version 5.6.0.

    Perl version: loaded 1310 times in 1 minute
    PHP version: loaded 1950 times in 1 minute

    pretty good for PHP! just thought i'd share with you guys. any comments?

    here's the code.

    Perl:
    Code:
    #!i:/program files/perl/bin/perl
    
    require 'subs.pl';
    
    if (exists $in{'num'})
    {
    $num = $in{'num'} + 1;
    }
    else
    {
    $num = 1;
    }
    
    print "Content-type: text/html\n\n";
    
    print <<EOTXT;
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
     "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    
    <head>
    <title>Benchmark - $num</title>
    
    <script type="text/javascript">
    function doSubmit()
    {
    document.bench.submit();
    }
    </script>
    </head>
    
    <body onload="doSubmit()">
    <div align="center">
    Benchmark $num
    
    <form name="bench" action="bench.pl" method="post">
    <input type="hidden" name="num" value="$num">
    <input type="submit" value="Submit">
    </form>
    </div>
    </body>
    
    </html>
    EOTXT
    PHP:
    PHP Code:
    <?php

    if (isset($num))
    {
    $num++;
    }
    else
    {
    $num 1;
    }
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
     "http://www.w3.org/TR/html4/loose.dtd">
    <html>

    <head>
    <title>Benchmark - <?php echo $num ?></title>

    <script type="text/javascript">
    function doSubmit()
    {
    document.bench.submit();
    }
    </script>
    </head>

    <body onload="doSubmit()">
    <div align="center">
    Benchmark <?php echo $num ?>

    <form name="bench" action="bench.php" method="post">
    <input type="hidden" name="num" value="<?php echo $num ?>">
    <input type="submit" value="Submit">
    </form>
    </div>
    </body>

    </html>
    Last edited by DR_LaRRY_PEpPeR; Jul 10, 2001 at 22:26.

  2. #2
    Fluffy Kitten Programmer~ Elledan's Avatar
    Join Date
    Jun 2000
    Location
    Netherlands
    Posts
    1,356
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, PHP is faster than Perl, because a Perl script must be compiled before it can be used
    www.nyanko.ws - My web-, software- and game development company.
    www.mayaposch.com - My personal site and blog.

  3. #3
    SitePoint Wizard westmich's Avatar
    Join Date
    Mar 2000
    Location
    Muskegon, MI
    Posts
    2,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Elledan
    Yes, PHP is faster than Perl, because a Perl script must be compiled before it can be used
    All code needs to be compiled

    Server-side languages like PHP, ASP, JSP, and Cold Fusion only need to do it once and then send repeat requests out of memory.
    Westmich
    Smart Web Solutions for Smart Clients
    http://www.mindscapecreative.com


Bookmarks

Posting Permissions

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