Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming > #4062

Re: Perl or PHP?

From "BartC" <bc@freeuk.com>
Newsgroups comp.programming
References <l9mruq$pn8$1@speranza.aioe.org> <db93pa-d0p.ln1@luuk.invalid.lan> <l9mt81$sqg$1@speranza.aioe.org> <98a3pa-0sq.ln1@luuk.invalid.lan>
Subject Re: Perl or PHP?
Message-ID <v2Ivu.1028$v04.766@fx28.am4> (permalink)
Organization virginmedia.com
Date 2013-12-28 22:13 +0000

Show all headers | View raw


"Luuk" <luuk@invalid.lan> wrote in message
news:98a3pa-0sq.ln1@luuk.invalid.lan...
> On 28-12-2013 17:11, Victor Porton wrote:

>> Could you disclose the content of files test.pl and test.php?
>>
>>> But the question of course is, what are your comparing?
>>>
>>> ;-)
>>
>
>   1 #!/usr/bin/perl
>   2
>   3 for ($count = 1000; $count >= 1; $count--) {
>   4                 print "$count ";
>   5                  }
>
>
> and
>
>   1 #!/usr/bin/php
>   2
>   3 <?php
>   4 for ($f=1000; $f>=1; $f--)
>   5         echo "$f ";

So you're mainly testing I/O rather than the language: which depends on the
commands that are used for output in the language, how they are implemented,
how the console is driven, the console implementation code, the kind of
display, etc.

Changing your tests a little so that the loops increment a variable, and
putting the output at the end, makes PHP twice as fast as Perl (on the same
setup which had PHP seven times slower than Perl using your tests.) Eg:

$a=0;
for ($count = 10000000; $count >= 1; $count--) {
                $a=$a+1;
etc.

Still a lousy benchmark, but at least it avoids I/O which is highly 
misleading.


-- 
Bartc 

Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Perl or PHP? Victor Porton <porton@narod.ru> - 2013-12-28 17:49 +0200
  Re: Perl or PHP? Victor Porton <porton@narod.ru> - 2013-12-28 17:51 +0200
  Re: Perl or PHP? Luuk <luuk@invalid.lan> - 2013-12-28 17:03 +0100
    Re: Perl or PHP? Victor Porton <porton@narod.ru> - 2013-12-28 18:11 +0200
      Re: Perl or PHP? Luuk <luuk@invalid.lan> - 2013-12-28 17:18 +0100
        Re: Perl or PHP? "BartC" <bc@freeuk.com> - 2013-12-28 22:13 +0000
          Re: Perl or PHP? Luuk <luuk@invalid.lan> - 2013-12-29 17:29 +0100
  Re: Perl or PHP? Victor Porton <porton@narod.ru> - 2013-12-28 20:40 +0200
    Re: Perl or PHP? Öö Tiib <ootiib@hot.ee> - 2013-12-28 12:26 -0800

csiph-web