--- test/html-whatpm/parser.cgi 2007/05/27 11:16:02 1.6
+++ test/html-whatpm/parser.cgi 2007/11/11 04:18:27 1.9
@@ -2,17 +2,16 @@
use strict;
use lib qw[/home/httpd/html/www/markup/html/whatpm
- /home/wakaba/public_html/-temp/wiki/lib];
+ /home/wakaba/work/manakai2/lib];
use CGI::Carp qw[fatalsToBrowser];
use Time::HiRes qw/time/;
-use SuikaWiki::Input::HTTP; ## TODO: Use some better CGI module
-
-my $http = SuikaWiki::Input::HTTP->new;
+use Message::CGI::HTTP;
+my $http = Message::CGI::HTTP->new;
## TODO: _charset_
-my $mode = $http->meta_variable ('PATH_INFO');
+my $mode = $http->get_meta_variable ('PATH_INFO');
## TODO: decode unreserved characters
if ($mode eq '/html' or $mode eq '/test') {
@@ -20,7 +19,7 @@
require Whatpm::HTML;
require Whatpm::NanoDOM;
- my $s = $http->parameter ('s');
+ my $s = $http->get_parameter ('s');
if (length $s > 1000_000) {
print STDOUT "Status: 400 Document Too Long\nContent-Type: text/plain; charset=us-ascii\n\nToo long";
exit;
@@ -30,6 +29,7 @@
$s = Encode::decode ('utf-8', $s);
my $time2 = time;
my %time = (decode => $time2 - $time1);
+ my $char_length = length $s;
print STDOUT "Content-Type: text/plain; charset=utf-8\n\n";
@@ -51,7 +51,8 @@
my $out;
$time1 = time;
if ($mode eq '/html') {
- $out = Whatpm::HTML->get_inner_html ($doc);
+ require Whatpm::HTML::Serializer;
+ $out = Whatpm::HTML::Serializer->get_inner_html ($doc);
} else { # test
$out = test_serialize ($doc);
}
@@ -60,7 +61,7 @@
print STDOUT Encode::encode ('utf-8', $$out);
print STDOUT "\n";
- if ($http->parameter ('dom5')) {
+ if ($http->get_parameter ('dom5')) {
require Whatpm::ContentChecker;
print STDOUT "#domerrors\n";
$time1 = time;
@@ -77,6 +78,11 @@
print STDOUT "html5->dom5\t", $time{parse}, "s\n";
print STDOUT "dom5->serialize\t", $time{serialize}, "s\n";
print STDOUT "dom5 check\t", $time{check}, "s\n" if defined $time{check};
+ for (qw/decode parse serialize check/) {
+ next unless defined $time{$_};
+ open my $file, '>>', ".$_.txt" or die ".$_.txt: $!";
+ print $file $char_length, "\t", $time{$_}, "\n";
+ }
} else {
print STDOUT "Status: 404 Not Found\nContent-Type: text/plain; charset=us-ascii\n\n404";
}
@@ -155,4 +161,4 @@
=cut
-## $Date: 2007/05/27 11:16:02 $
+## $Date: 2007/11/11 04:18:27 $