Commit | Line | Data |
24490789 |
1 | #!perl -w |
2 | |
3 | use strict; |
4 | use Config; printf "Perl/%vd (%s)\n", $^V, $Config{archname}; |
5 | |
6 | use Benchmark qw(:hireswallclock); |
7 | use Benchmark::Forking qw(cmpthese); |
8 | |
9 | use Encode (); # pre-load for Interface::Test |
10 | use HTTP::Request (); |
11 | |
12 | sub new_he{ |
13 | my($use_pp) = @_; |
14 | $ENV{MOUSE_PUREPERL} = $use_pp; |
15 | |
16 | require HTTP::Engine; |
17 | |
18 | return HTTP::Engine->new( |
19 | interface => { |
20 | module => 'Test', |
21 | request_handler => sub { |
22 | my($request) = @_; |
23 | |
24 | return HTTP::Engine::Response->new(body => "Hello, world!\n"); |
25 | }, |
26 | }, |
27 | ); |
28 | } |
29 | |
30 | my $req = HTTP::Request->new(GET => 'http://localhost/'); |
31 | |
32 | print "load HTTP::Engine, new(), and run()\n"; |
33 | cmpthese -1 => { |
34 | 'XS' => sub { |
35 | my $he = new_he(0); |
36 | $he->run($req, env => \%ENV); |
37 | }, |
38 | 'PP' => sub { |
39 | my $he = new_he(1); |
40 | $he->run($req, env => \%ENV); |
41 | }, |
42 | }; |
43 | |
44 | print "load HTTP::Engine, new(), and run() * 100\n"; |
45 | cmpthese -1 => { |
46 | 'XS' => sub { |
47 | my $he = new_he(0); |
48 | $he->run($req, env => \%ENV) for 1 .. 100; |
49 | }, |
50 | 'PP' => sub { |
51 | my $he = new_he(1); |
52 | $he->run($req, env => \%ENV) for 1 .. 100; |
53 | }, |
54 | }; |
55 | |