|
|
ru.cgi.perl- RU.CGI.PERL ------------------------------------------------------------------ From : Vovik Alyekhin 2:4615/59 16 Mar 2001 09:56:42 To : Pavel Kurnosoff Subject : Загрузить HTML с параметрами --------------------------------------------------------------------------------
Hello Pavel!
16 Мар 01 00:56, Pavel Kurnosoff писал(а) к Vovik Alyekhin:
VA>> 2ALL: Hарод, а это только у меня Template-Toolkit работает
VA>> медленнее HTML::Template в 3 раза или еще у кого?
PK> а каких условиях мерял?
Да я сильно не заморачивался, тупой вывод %ENV в виде таблички.
Модули "из коробки", никаких настроек дополнительных не было.
HTML::Template:
===============
Собственно код:
#!/usr/bin/perl
use HTML::Template;
use strict;
my $tmpl=HTML::Template->new(filename=>'ht.tmpl');
my @table;
foreach (sort keys %ENV){
my %row;
$row{name}=$_;
$row{value}=$ENV{$_};
push @table, \%row;
}
$tmpl->param(table=>\@table);
print "Content-type: text/html\n\n",$tmpl->output;
Шаблон:
<html></body>
<table border=1>
<tmpl_loop table>
<tr><td><tmpl_var name></td><td><tmpl_var value></td></tr>
</tmpl_loop>
</table>
</body></html>
Template-Toolkit:
=================
Собственно код:
#!/usr/bin/perl
use Template;
use strict;
my $tmpl=Template->new();
my @table;
foreach (sort keys %ENV){
my %row;
$row{name}=$_;
$row{value}=$ENV{$_};
push @table, \%row;
}
my %data= (table=>\@table);
print "Content-type: text/html\n\n";
$tmpl->process('t.tmpl', \%data)|| die $tmpl->error();
Шаблон:
<html></body>
<table border=1>
[% FOREACH row = table %]
<tr><td>[% row.name %]</td><td>[% row.value %]</td></tr>
[% END %]
</table>
</body></html>
А вот результаты:
HTML::Template:
===============
This is ApacheBench, Version 1.3c <$Revision: 1.1.1.3 $> apache-1.3
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2000 The Apache Group, http://www.apache.org/
Server Software: Apache/1.3.17
Server Hostname: localhost
Server Port: 80
Document Path: /cgi-bin/test/ht.pl
Document Length: 1487 bytes
Concurrency Level: 1
Time taken for tests: 33.268 seconds
Complete requests: 100
Failed requests: 0
Total transferred: 173000 bytes
HTML transferred: 148700 bytes
>Requests per second: 3.01
>Transfer rate: 5.20 kb/s received
Connnection Times (ms)
min avg max
Connect: 0 0 0
Processing: 279 332 1299
Total: 279 332 1299
Template-Toolkit:
=================
This is ApacheBench, Version 1.3c <$Revision: 1.1.1.3 $> apache-1.3
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2000 The Apache Group, http://www.apache.org/
Server Software: Apache/1.3.17
Server Hostname: localhost
Server Port: 80
Document Path: /cgi-bin/test/t.pl
Document Length: 1484 bytes
Concurrency Level: 1
Time taken for tests: 84.549 seconds
Complete requests: 100
Failed requests: 0
Total transferred: 172700 bytes
HTML transferred: 148400 bytes
>Requests per second: 1.18
>Transfer rate: 2.04 kb/s received
Connnection Times (ms)
min avg max
Connect: 0 0 0
Processing: 725 845 1354
Total: 725 845 1354
Вот так вот. Если я что не так делал - просьба ткнуть носом.
PS. То что mod_perl/mason быстрее я знаю :)
With best regards Vovik 16 Мар 01 г. 08:36
[Team Depeche Mode]
... Hе стоит прогибаться под изменчивый мир,пусть лучше он прогнется под нас...
--- e-mail: avovik@iname.com ICQ UIN: 30831526 ,,,^..^,,,
* Origin: -<< AV Station,Lugansk,Ukraine >>- (2:4615/59)
Вернуться к списку тем, сортированных по: возрастание даты уменьшение даты тема автор
Архивное /ru.cgi.perl/18943ab1b937.html, оценка из 5, голосов 10
|