Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Faster way to get PHP script than LWP::Simple

Reply
Thread Tools

Faster way to get PHP script than LWP::Simple

 
 
Jason Carlton
Guest
Posts: n/a
 
      11-29-2009
I'm using a PHP script as a heading for the site, and it has several
functions in it. If I want to include this header in a Perl script, is
there a better / faster way than using LWP::Simple?

I ask because I've noticed that my Perl-based pages load a little
slower than other pages on the site (even a plain "Hello World" script
that includes this header), so I'm pretty sure that this is the
bottleneck.
 
Reply With Quote
 
 
 
 
smallpond
Guest
Posts: n/a
 
      11-29-2009
On Nov 28, 9:50*pm, Jason Carlton <jwcarl...@gmail.com> wrote:
> I'm using a PHP script as a heading for the site, and it has several
> functions in it. If I want to include this header in a Perl script, is
> there a better / faster way than using LWP::Simple?
>
> I ask because I've noticed that my Perl-based pages load a little
> slower than other pages on the site (even a plain "Hello World" script
> that includes this header), so I'm pretty sure that this is the
> bottleneck.


time perl -e 'use LWP::Simple; print "Hello, World"'
Hello, World
real 0m0.033s
user 0m0.026s
sys 0m0.007s

You must be very perceptive. Most people
wouldn't notice that delay.
 
Reply With Quote
 
 
 
 
Peter J. Holzer
Guest
Posts: n/a
 
      11-29-2009
On 2009-11-29 18:28, smallpond <> wrote:
> On Nov 28, 9:50*pm, Jason Carlton <jwcarl...@gmail.com> wrote:
>> I'm using a PHP script as a heading for the site, and it has several
>> functions in it. If I want to include this header in a Perl script, is
>> there a better / faster way than using LWP::Simple?
>>
>> I ask because I've noticed that my Perl-based pages load a little
>> slower


I assume "a little slower" means a few tenth's of a second?

>> than other pages on the site (even a plain "Hello World" script that
>> includes this header), so I'm pretty sure that this is the
>> bottleneck.

>
> time perl -e 'use LWP::Simple; print "Hello, World"'
> Hello, World
> real 0m0.033s
> user 0m0.026s
> sys 0m0.007s
>
> You must be very perceptive. Most people
> wouldn't notice that delay.


I'm quite sure that he doesn't just load LWP::Simple without using it.

From the description he uses LWP::Simple to get a PHP-generated page,
then extracts the header from it and includes it in the output of his
Perl script.

So the total time is:

1) startup of the perl script (if this is CGI, this includes loading the
perl interpreter and all modules used by the script)
2) plus the time for fetching the PHP page
3) plus the time for extracting the header (almost certainly negligible)
4) plus the time the script spends on doing "real work".

So loading a perl page always takes as long as loading a PHP page
(because loading a perl page *does* load a PHP page, too!) plus some
extra time.

Obvious optimizations are:

* If you have to load a PHP page every time you load a perl page, then
at least load one which is short and loads fast! Don't load your
start page which searches for your last n blog entries, does a google
search for your name and aggregates 52 atom feeds just to throw all
that information away immediately.
* Cache the result of the query. If you use FastCGI or mod_perl, you
can simply keep the header in a variable. If you don't you can put it
in a file or stuff it into memcached.
* Use FastCGI or mod_perl. The time to load the perl interpreter may be
negligible these days, but some other actions aren't. For example
opening a database connection is still rather slow, and if you can do
that only once instead of for each request you win.

hp
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Training Institute In Delhi, Live Projects on PHP. Short TermPHP Courses, PHP Scripts, PHP Training with Live Projects. Rajive Narain Java 0 09-18-2009 10:47 AM
How to get a text input value into a php script Todor Vachkov Javascript 3 04-13-2007 05:41 PM
Faster way to execute contents of a perl script? Brandon Hoppe Perl Misc 7 03-11-2005 05:49 PM
Get connected users number from php script...... Giuseppe Javascript 0 01-16-2005 02:54 PM
Is there any faster way than dynamic_cast to find the object run time type? steve C++ 17 09-13-2004 08:19 PM



Advertisments