This is an automated email from the git hooks/post-receive script.

gregoa pushed a commit to tag 0.01
in repository libhttp-entity-parser-perl.

commit fcb6fa1cf70c3eabadbd643548287fc871e3aa44
Author: Masahiro Nagano <kazeb...@gmail.com>
Date:   Wed Feb 5 10:37:21 2014 +0900

    add benchmark
---
 eg/bench.pl | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/eg/bench.pl b/eg/bench.pl
new file mode 100644
index 0000000..e2edbde
--- /dev/null
+++ b/eg/bench.pl
@@ -0,0 +1,41 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use HTTP::Entity::Parser;
+use HTTP::Body;
+use Benchmark qw/:all/;
+
+my $content = 'xxx=hogehoge&yyy=aaaaaaaaaaaaaaaaaaaaa';
+
+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;
+    }
+}));
+
+__END__
+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) @ 36201.85/s 
(n=39098)
+http_entity:  1 wallclock secs ( 1.10 usr +  0.01 sys =  1.11 CPU) @ 
51661.26/s (n=57344)
+               Rate   http_body http_entity
+http_body   36202/s          --        -30%
+http_entity 51661/s         43%          --
+

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-perl/packages/libhttp-entity-parser-perl.git

_______________________________________________
Pkg-perl-cvs-commits mailing list
Pkg-perl-cvs-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits

Reply via email to