Fix docs. The phrases "Fewer than 1%" and "over 96%" are very confusing, so I removed...
[gitmo/Mouse.git] / author / pp-vs-xs-with-forking.pl
CommitLineData
24490789 1#!perl -w
2
3use strict;
4use Config; printf "Perl/%vd (%s)\n", $^V, $Config{archname};
5
6use Benchmark qw(:hireswallclock);
7use Benchmark::Forking qw(cmpthese);
8
9use Encode (); # pre-load for Interface::Test
10use HTTP::Request ();
11
12sub 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
30my $req = HTTP::Request->new(GET => 'http://localhost/');
31
32print "load HTTP::Engine, new(), and run()\n";
33cmpthese -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
44print "load HTTP::Engine, new(), and run() * 100\n";
45cmpthese -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