[libhttp-entity-parser-perl] 04/05: update benchmark
gregor herrmann
gregoa at debian.org
Sun Oct 23 00:23:35 UTC 2016
This is an automated email from the git hooks/post-receive script.
gregoa pushed a commit to tag 0.03
in repository libhttp-entity-parser-perl.
commit 9fa7338dffe89bdf53e82c9dec4749beacaf545a
Author: Masahiro Nagano <kazeburo at gmail.com>
Date: Fri Feb 7 16:02:06 2014 +0900
update benchmark
---
eg/bench.pl | 83 +++++++++++++++++++++++++++++++----------------
lib/HTTP/Entity/Parser.pm | 6 +++-
2 files changed, 60 insertions(+), 29 deletions(-)
diff --git a/eg/bench.pl b/eg/bench.pl
index 4de4e5c..1e7ab05 100644
--- a/eg/bench.pl
+++ b/eg/bench.pl
@@ -6,36 +6,63 @@ use HTTP::Entity::Parser;
use HTTP::Body;
use Benchmark qw/:all/;
-my $content = 'xxx=hogehoge&yyy=aaaaaaaaaaaaaaaaaaaaa&%E6%97%A5%E6%9C%AC%E8%AA%9E=%E3%81%AB%E3%81%BB%E3%82%93%E3%81%94&%E3%81%BB%E3%81%92%E3%81%BB%E3%81%92=%E3%81%B5%E3%81%8C%E3%81%B5%E3%81%8C';
-
-my $parser = HTTP::Entity::Parser->new;
-$parser->register('application/x-www-form-urlencoded','HTTP::Entity::Parser::UrlEncoded');
-
-cmpthese(timethese(-1, {
- 'http_entity' => sub {
- open my $input, '<', \$content;
- my $env = {
- 'psgi.input' => $input,
- 'psgix.input.buffered' => 1,
- CONTENT_LENGTH => length($content),
- CONTENT_TYPE => 'application/x-www-form-urlencoded',
- };
- $parser->parse($env);
- },
- 'http_body' => sub {
- open my $input, '<', \$content;
- my $body = HTTP::Body->new( 'application/x-www-form-urlencoded', length($content) );
- $input->read( my $buffer, 8192);
- $body->add($buffer);
- $body->param;
- }
-}));
+my $content1 = 'xxx=hogehoge&yyy=aaaaaaaaaaaaaaaaaaaaa';
+
+my $content2 = 'xxx=hogehoge&yyy=aaaaaaaaaaaaaaaaaaaaa&%E6%97%A5%E6%9C%AC%E8%AA%9E=%E3%81%AB%E3%81%BB%E3%82%93%E3%81%94&%E3%81%BB%E3%81%92%E3%81%BB%E3%81%92=%E3%81%B5%E3%81%8C%E3%81%B5%E3%81%8C';
+
+my $content3 = join '&', map { "$_=%E3%81%B5%E3%81%8C%E3%81%B5%E3%81%8C%E3%81%B5%E3%81%8C%E3%81%B5%E3%81%8C%E3%81%B5%E3%81%8C%E3%81%B5%E3%81%8C" } 'A'..'R';
+
+ my $parser = HTTP::Entity::Parser->new;
+ $parser->register('application/x-www-form-urlencoded','HTTP::Entity::Parser::UrlEncoded');
+
+for my $content ($content1, $content2, $content3) {
+ print "\n## content length => ", length($content) . "\n\n";
+ cmpthese(timethese(-1, {
+ 'http_entity' => sub {
+ open my $input, '<', \$content;
+ my $env = {
+ 'psgi.input' => $input,
+ 'psgix.input.buffered' => 1,
+ CONTENT_LENGTH => length($content),
+ CONTENT_TYPE => 'application/x-www-form-urlencoded',
+ };
+ $parser->parse($env);
+ },
+ 'http_body' => sub {
+ open my $input, '<', \$content;
+ my $body = HTTP::Body->new( 'application/x-www-form-urlencoded', length($content) );
+ $input->read( my $buffer, 8192);
+ $body->add($buffer);
+ $body->param;
+ }
+ }));
+}
__END__
+
+## content length => 38
+
Benchmark: running http_body, http_entity for at least 1 CPU seconds...
- http_body: 1 wallclock secs ( 1.08 usr + 0.00 sys = 1.08 CPU) @ 14339.81/s (n=15487)
-http_entity: 2 wallclock secs ( 1.10 usr + 0.00 sys = 1.10 CPU) @ 65162.73/s (n=71679)
+ http_body: 1 wallclock secs ( 1.08 usr + 0.00 sys = 1.08 CPU) @ 36201.85/s (n=39098)
+http_entity: 1 wallclock secs ( 1.12 usr + 0.00 sys = 1.12 CPU) @ 76799.11/s (n=86015)
Rate http_body http_entity
-http_body 14340/s -- -78%
-http_entity 65163/s 354% --
+http_body 36202/s -- -53%
+http_entity 76799/s 112% --
+
+## content length => 177
+Benchmark: running http_body, http_entity for at least 1 CPU seconds...
+ http_body: 1 wallclock secs ( 1.11 usr + 0.00 sys = 1.11 CPU) @ 14901.80/s (n=16541)
+http_entity: 1 wallclock secs ( 1.08 usr + 0.00 sys = 1.08 CPU) @ 64474.07/s (n=69632)
+ Rate http_body http_entity
+http_body 14902/s -- -77%
+http_entity 64474/s 333% --
+
+## content length => 1997
+
+Benchmark: running http_body, http_entity for at least 1 CPU seconds...
+ http_body: 1 wallclock secs ( 1.16 usr + 0.00 sys = 1.16 CPU) @ 1930.17/s (n=2239)
+http_entity: 1 wallclock secs ( 1.11 usr + 0.00 sys = 1.11 CPU) @ 29519.82/s (n=32767)
+ Rate http_body http_entity
+http_body 1930/s -- -93%
+http_entity 29520/s 1429% --
diff --git a/lib/HTTP/Entity/Parser.pm b/lib/HTTP/Entity/Parser.pm
index b4573e7..dcbbac3 100644
--- a/lib/HTTP/Entity/Parser.pm
+++ b/lib/HTTP/Entity/Parser.pm
@@ -231,10 +231,14 @@ HTTP::Entity::Parser is able to choose parsers by the instance, HTTP::Body requi
=item L<HTTP::Body>
-=item L<HTTP::MultiPartParser>.
+=item L<HTTP::MultiPartParser>
=item L<Plack::Request>
+=item L<WWW::Form::UrlEncoded>
+
+HTTP::Entity::Parser uses this for parse application/x-www-form-urlencoded
+
=back
=head1 LICENSE
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libhttp-entity-parser-perl.git
More information about the Pkg-perl-cvs-commits
mailing list