Hi again,
So i've set up a simple test case with the following code:
(basically what happens all the time in my site)
##########################################################
#!/usr/bin/perl -Tw
use strict;
use DBI;
use Petal;
use Time::HiRes;
my $ts = [Time::HiRes::gettimeofday];
my $dbh = DBI->connect(
"dbi:mysql:dbnivre:localhost:3306",
"xxx",
"xxx",
{
RaiseError => 1,
AutoCommit => 1
})
or die ($DBI::errstr);
my $sql = "SELECT t.name, t.value FROM tbtest t;";
my $dbs = $dbh->prepare($sql);
$dbs->execute();
my $items = [];
my $self = {};
while (my $r = $dbs->fetchrow_hashref) {
push(@{$items},$r);
}
my $pt = Petal->new(
file => "items.xhtml",
base_dir => "/var/www/nivre.net",
input => "XHTML",
output => "XHTML",
taint => 1,
disk_cache => 0,
);
my $pr = $pt->process(
items => $items
);
$self->{content} = $pr;
$pt = Petal->new(
file => "main.xhtml",
base_dir => "/var/www/nivre.net",
input => "XHTML",
output => "XHTML",
taint => 1,
disk_cache => 0,
);
$pr = $pt->process(
app => $self
);
my $te = [Time::HiRes::gettimeofday];
my $ms = sprintf("%.3f",Time::HiRes::tv_interval($ts,$te));
print "Content-Type: text/html\n\n";
print $pr;
print "mod_perl: ".$ENV{MOD_PERL}."<br/>\n";
print "Execution time: ".$ms."\n";
##########################################################
I added 2 vhosts to apache, one time with mod_perl one time without.
You can see the results here:
http://www.nivre.net/ (mod_perl)
http://www-cgi.nivre.net/ (cgi)
The strange thing is, now the mod_perl version is fast as hell after
the first request (so caching seems to work).
So maybe my cry for help was false alarm, but thanks for the answers
anyway. I don't think i changed anything, maybe it was the server load
in general or something.
So long,
Dietmar