HTTP::Parser::XS - a PSGI compatible, fast http parser
ãã¼ãã¨æã£ã¦ãæ¸ãããGitHub - kazuho/p5-http-parser-xs: a fast http parser
BLURB ã¯ã
- PSGI ã®ãªã¯ã¨ã¹ããªãã¸ã§ã¯ããè¿ã
- é«é
- åæ httpd, éåæ httpd ã®ã©ã¡ããå®è£ ããéã«ã使ç¨å¯è½
- POST ã³ã³ãã³ãã®ãã³ããªã³ã°ã¯ãèªåã§
- ãã£ãããã¡ã¤ã«ã«å ¥ããããããããè¦ä»¶ããããããã¼ã¹ä½æ¥ã¯çºçããªãã®ã§ Perl ã§ããã¾ãé ããªããªããã
ã¦ãªæãã§ãã以ä¸ãã³ããã¼ã¯ã
$ ./http-parser-vs-xs-benchmark.pl Rate HTTP::Parser HTTP::Parser::XS HTTP::Parser 2978/s -- -95% HTTP::Parser::XS 54348/s 1725% --
ãã³ããã¼ã¯ã«ä½¿ã£ãã³ã¼ãã¯ã以ä¸ã®ã¨ããã
#! /usr/bin/perl use strict; use warnings; use Benchmark qw(cmpthese); use HTTP::Parser; use HTTP::Parser::XS qw(parse_http_request); my $req = "GET / HTTP/1.0\r\n\r\n"; my $http_parser = HTTP::Parser->new(); my %xs_env; cmpthese(100000, { 'HTTP::Parser' => sub { my $status = $http_parser->add($req); if ($status == 0) { $http_parser->request(); } else { die "oh!\n"; } }, 'HTTP::Parser::XS' => sub { my $len = parse_http_request($req, \%xs_env); if ($len >= 0) { # ok } else { die "agh!\n"; } }, });