CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
very simple perl CGI script performance is bad

 



ningji
Novice

May 13, 2013, 3:42 PM

Post #1 of 6 (292 views)
very simple perl CGI script performance is bad Can't Post

have a very simple webpage, it calls an executable and formats the output to the webpage (in tables).

if i run this exe in the linux shell 20 times, back to back, cpu hits 50%.

if i run the script,
perl myWebPage.pl
20 times, back to back, cpu stays in 90% for a long time.

How can i improve the performance of this web page pls ?


FishMonger
Veteran / Moderator

May 13, 2013, 7:33 PM

Post #2 of 6 (285 views)
Re: [ningji] very simple perl CGI script performance is bad [In reply to] Can't Post

It's not possible for us to troubleshoot code that you haven't shown.

You can use the Devel::NYTProf module to profile your script to find out where it's spending most of it's time and then look at reworking those sections to be more efficient.

http://search.cpan.org/~timb/Devel-NYTProf-5.02/lib/Devel/NYTProf.pm

If you want to post your script, we might be able to point out obvious inefficiencies.


(This post was edited by FishMonger on May 13, 2013, 7:33 PM)


ningji
Novice

May 14, 2013, 11:39 AM

Post #3 of 6 (277 views)
Re: [FishMonger] very simple perl CGI script performance is bad [In reply to] Can't Post

#!/usr/bin/perl -w

BEGIN { push @INC, "/usr/share/perl5"; }
BEGIN { push @INC, "/usr/share/perl5/CGI"; }

use CGI;
use POSIX;

my $totalObjStore;

##########################################
# Argu: file name
##########################################

##########################################
# main function
##########################################
my $i = 0;
my @rowOdd;
my @rowEven;

$mycgi = CGI->new;
print $mycgi->header,
$mycgi->start_html(-title=>'Nav', -bgcolor=>'#a9d0f5'),

$mycgi->header('text/html'),

$mycgi->h5({-align=>'center',
-color=>'#003366',
},

'Copyright (c) 2013'),

$mycgi->end_html;


FishMonger
Veteran / Moderator

May 14, 2013, 11:52 AM

Post #4 of 6 (274 views)
Re: [ningji] very simple perl CGI script performance is bad [In reply to] Can't Post

You've got to be joking.

Please post the info we need to be able to assist you, or don't waste our time.


(This post was edited by FishMonger on May 14, 2013, 11:52 AM)


ningji
Novice

May 14, 2013, 11:58 AM

Post #5 of 6 (271 views)
Re: [FishMonger] very simple perl CGI script performance is bad [In reply to] Can't Post

i'm not joking at all, :(

This is an Ateml A9 board, i'm using lighttpd.

This is what i traced down so far.
If i run 1 instance of "perl 1.pl &", cpu hit 20%.
If i run 2, cpu hit 40%.
...


In Reply To
You've got to be joking.

Please post the info we need to be able to assist you, or don't waste our time.



FishMonger
Veteran / Moderator

May 14, 2013, 12:16 PM

Post #6 of 6 (266 views)
Re: [ningji] very simple perl CGI script performance is bad [In reply to] Can't Post


Quote
have a very simple webpage, it calls an executable and formats the output to the webpage (in tables).


The code you posted doesn't even come close to doing what you stated.

Why are you printing the header twice?

If the code you posted uses 20% or more of the cpu, then obviously you must be running this on a 20 yr old 386 computer.


Quote

Code
BEGIN { push @INC, "/usr/share/perl5"; } 
BEGIN { push @INC, "/usr/share/perl5/CGI"; }


Is better written as:

Code
use lib '/usr/share/perl5'; 
use lib '/usr/share/perl5/CGI';


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives