Skip to content

use HTTP::Headers::Fast->flatten introduced 0.20#540

Merged
miyagawa merged 1 commit intoplack:masterfrom
kazeburo:use-http-header-fast-flatten
Nov 24, 2015
Merged

use HTTP::Headers::Fast->flatten introduced 0.20#540
miyagawa merged 1 commit intoplack:masterfrom
kazeburo:use-http-header-fast-flatten

Conversation

@kazeburo
Copy link
Copy Markdown
Contributor

HTTP::Headers::Fast->flatten was introduced in tokuhirom/HTTP-Headers-Fast#8. flatten is shortcut method for building PSGI compatible header array. This PR uses that.

benchmark. Would be 10% faster.

master

% perl bench.pl
Benchmark: running bench_hello for at least 3 CPU seconds...
bench_hello:  4 wallclock secs ( 3.22 usr +  0.00 sys =  3.22 CPU) @ 60104.35/s (n=193536)
               Rate bench_hello
bench_hello 60104/s          --

This PR

% perl -Ilib bench.pl
Benchmark: running bench_hello for at least 3 CPU seconds...
bench_hello:  4 wallclock secs ( 3.30 usr +  0.01 sys =  3.31 CPU) @ 66011.48/s (n=218498)
               Rate bench_hello
bench_hello 66011/s          --

benchmark script

use HTTP::Request::Common;
use HTTP::Message::PSGI;
use Plack::Response;
use Benchmark qw/cmpthese timethese/;

my $env = req_to_psgi(GET "/");
my $app = sub {
    my $res = Plack::Response->new(200);
    $res->content_type('text/plain');
    $res->body("Hello World\n");
    $res->finalize;
};

cmpthese(timethese(0,{
    'bench_hello' => sub {
        $app->($env);
    }
}));


miyagawa added a commit that referenced this pull request Nov 24, 2015
use HTTP::Headers::Fast->flatten introduced 0.20
@miyagawa miyagawa merged commit 0a69c4b into plack:master Nov 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants