PHP is better than perl and what can i do to run perl faster?
eial
created: 2004-06-14 00:22:29
I have two question...

What can i do to run perl faster and why php is faster than perl

I'm use php just like a module on apache and perl with sheband

but my big question is php is better than perl?

maybe, becouse php have too many function in your own core just like session, and on perl i have to create this, that is the problem?

Thank for your big help, again.
Re: PHP is better than perl and what can i do to run perl faster?
created: 2004-06-14 00:41:07

My first guess would be because PHP is being launched as a component of the webserver, while each time the perl script is called it is launched as an independent process. (I suspect PHP would not seem so much faster if it were being used as a CGI, rather than being loaded as a webserver module.) I would suggest if it is a significant concern perhaps a look at something such as mod_perl, where a perl interpreter would be loaded with the webserver and thus not have to be launched anew each time a call is made to that script.

My own experience with regards to mod_perl is limited, however, so I defer to those other monks herein who may have more experience with it.

Hope that helps...

Re: PHP is better than perl and what can i do to run perl faster?
created: 2004-06-14 03:04:36
What can i do to run perl faster and why php is faster than perl I'm use php just like a module on apache and perl with sheband
When PHP is used as a module, the interpreter is retained in memory, so there is no overhead for starting one up with each request to a PHP script.
but my big question is php is better than perl?
That depends entirely on what you're trying to do.

Arjen

Re: PHP is better than perl and what can i do to run perl faster?
created: 2004-06-14 03:07:32

As atcroft posited, I would also have to believe that the culprit is Perl being run as a CGI application rather than loaded as a module in the webserver. PHP isn't necessarily faster than Perl. There have been numerous comparisons on this subject, I would Google for Perl vs PHP or search on slashdot for language comparisons.

When Perl is *NOT* run as a webserver module, every page call requires that a new Perl interpreter is spawned. This quickly becomes very expensive, both in terms of memory and CPU utilization. When Perl is run as a webserver module, one instance of the interpreter is started with the webserver and multiple threads of execution are used. The big advantage of this is that each page/script is cached in memory (in theory forever, but memory constraints might not allow for this), the memory caching allows existing scripts to be run very quickly. The scripts never need be recompiled for every page view (as they might be with a CGI application).

Hope this helps.

jeremiah



If you make something idiot-proof, eventually someone will make a better idiot.
I am that better idiot.
Re^2: PHP is better than perl and what can i do to run perl faster?
created: 2004-06-14 03:23:53
"When Perl is run as a webserver module, one instance of the interpreter is started with the webserver and multiple threads of execution are used"

Correct me if I'm wrong but with mod_perl (Apache), we have one instance of the Perl interpreter for each thread/process of the WebServer, and not the apposite.

We also doesn't have memory cache of "pages", unless this is implemented over a embeded html system, like HTML::Mason. What we have is that for each execution of a mod_perl module we are just continuing the execution of the module, so, is like to have a script that doesn't die and only need to be parsed and started 1 time, what is much more faster.

Graciliano M. P.
"Creativity is the expression of the liberty".

Re^3: PHP is better than perl and what can i do to run perl faster?
created: 2004-06-14 03:49:51

"When Perl is run as a webserver module, one instance of the interpreter is started with the webserver and multiple threads of execution are used"

Correct me if I'm wrong but with mod_perl (Apache), we have one instance of the Perl interpreter for each thread/process of the WebServer, and not the apposite.

The key word is "started". While each mod_perl process has their own copy of the perl interpreter you only suffer the time expense of starting up perl and loading modules the one time. After that it's just cheap forks.

Re: PHP is better than perl and what can i do to run perl faster?
created: 2004-06-14 03:15:36
Have you tried mod_perl?

http://perl.apache.org

Graciliano M. P.
"Creativity is the expression of the liberty".

Re: PHP is better than perl and what can i do to run perl faster?
created: 2004-06-14 06:56:26
PHP was created by teenagers for teenagers and as such is a deliberately dumbed-down version of Perl (PHP5 still lacks namespaces).

If you want to speed up your cgi, try SpeedyCGI, FastCGI or mod_perl.

For sessions in Perl, try this: Session
Re^2: PHP is better than perl and what can i do to run perl faster?
created: 2004-06-14 18:55:04
Yes, people i understand.

But i wrote the same program in php and perl, when i tested both programs, perl took 2.3 second to process all, and php only took 0.2 second.

Why?

I wrote both program with the best way.

if use mod_perl this reduce only few millisecond but not change in the significative form.

i think that because php include some function in your own core, this maybe make the diference, it's correct or not?

is very very important to resolve that, for me.

But, i'm grateful for your help.
Re^3: PHP is better than perl and what can i do to run perl faster?
created: 2004-06-14 19:08:42
In every test I've ever seen, equivalent code runs slightly faster under mod_perl than PHP. Are you saying that you ran it under mod_perl and it wasn't much faster? That means you're either not really running it through mod_perl, or there is something slow about the way you wrote it in Perl. Show us your httpd.conf file and your code and we can help.
Re^4: PHP is better than perl and what can i do to run perl faster?
created: 2004-06-14 22:30:20
yes, in fact at this moment i'm use perl with mod_perl

look this, is a fragment of httpd.conf:

...
LoadModule perl_module modules/mod_perl.so
LoadModule php4_module c:/windows/php/sapi/php4apache2.dll
...

In the code of perl script load dbi,image magic,cgi,digest modules but i'm very sure, that both script haven't something bad, i'm check both code many times.

it's only perl that run slownly, or can't run faster.

maybe itsn't a problem just perl is slownly than php, can be?

Or must be faster than php.

anyone test that?

Thank for your help.
Re^5: PHP is better than perl and what can i do to run perl faster?
created: 2004-06-14 22:43:14
That's not the part of your httpd.conf I wanted to see. Please post the part where you tell it to use Apache::Registry. You can verify that your script is running under mod_perl and not CGI by printing out the value of the environment variable $ENV{'MOD_PERL'}.

The CGI modules is not very fast, and not necessary when using mod_perl.

Perl is not slower than PHP. Here is one benchmark: http://www.chamas.com/bench/ There was also a Yahoo benchmark which showed mod_perl outperforming PHP. The numbers are always pretty close though.

Re^6: PHP is better than perl and what can i do to run perl faster?
created: 2004-06-15 14:10:05
OK, thank, well, i will check this and report what happend
Thank again
Re: PHP is better than perl and what can i do to run perl faster?
created: 2004-06-15 14:46:26

What can i do to run perl faster

If you properly modularized your code, profiling it should be easy. If it's code that will only run in mod_perl, profiling it will be very hard. Several profiling modules are available. Search CPAN.

why php is faster than perl

I've found it very hard to find PHP scripts that didn't have faster Perl equivalents. But for static pages, that is: pages with no content, PHP certainly is faster than a Perl script that prints the same text, even if $r->print is used. I do not know why this is, and have no urge to find out. It shouldn't matter anyway, because for static pages, you don't need to use a programming language.

is php is better than perl?

Certainly not. PHP is much, much worse than Perl. Please read http://tnx.nl/php.txt for a comparison of some very important aspects.

php have too many function in your own core just like session, and on perl i have to create this

No, you don't have to re-invent the wheel. Others have coded things like support for sessions. All you need to do is install a module and learn to use it. It's probably a bit more work to get the session ID across, but in return you get all the flexibility you could ask for.

hth

Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

perlmonks.org content © perlmonks.org and adrianh, Aragorn, Arunbear, atcroft, eial, gmpassos, Juerd, perrin, peschkaj

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03