Commit | Line | Data |
d10b9732 |
1 | #!/usr/bin/perl |
2 | |
3 | BEGIN { |
4 | require FindBin; |
5 | } |
6 | |
7 | use strict; |
8 | use warnings; |
9 | use lib "$FindBin::Bin/../lib"; |
712c90b5 |
10 | use lib "$FindBin::Bin/../t/lib"; |
d10b9732 |
11 | |
12 | use Benchmark qw[timethese]; |
13 | use HTTP::Body qw[]; |
14 | use IO::File qw[O_RDONLY]; |
712c90b5 |
15 | use PAML qw[LoadFile]; |
d10b9732 |
16 | |
712c90b5 |
17 | my $headers = LoadFile("t/data/multipart/003-headers.pml"); |
d10b9732 |
18 | |
19 | my $run = sub { |
20 | my $bsize = shift; |
21 | my $content = IO::File->new( "$FindBin::Bin/../t/data/multipart/003-content.dat", O_RDONLY ); |
22 | my $body = HTTP::Body->new( $headers->{'Content-Type'}, $headers->{'Content-Length'} ); |
23 | |
24 | binmode($content); |
25 | |
26 | while ( $content->sysread( my $buffer, $bsize ) ) { |
27 | $body->add($buffer); |
28 | } |
29 | |
30 | unless ( $body->state eq 'done' ) { |
31 | die 'baaaaaaaaad'; |
32 | } |
33 | }; |
34 | |
35 | |
36 | timethese( 1_000, { |
37 | 'HTTP::Body 256' => sub { $run->(256) }, |
38 | 'HTTP::Body 1024' => sub { $run->(1024) }, |
39 | 'HTTP::Body 4096' => sub { $run->(4096) }, |
40 | 'HTTP::Body 8192' => sub { $run->(8192) }, |
41 | }); |