Profile of HTTP/Body/UrlEncoded.pm

← Index
NYTProf Performance Profile «line view»
For script/ponapi
Run on Wed Feb 10 15:51:26 2016
Reported on Thu Feb 11 09:43:09 2016

Filename | /usr/local/share/perl/5.18.2/HTTP/Body/UrlEncoded.pm
Statements | Executed 524 statements in 581µs

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
1 | 1 | 1 | 12µs | 24µs | HTTP::Body::UrlEncoded::::BEGIN@6HTTP::Body::UrlEncoded::BEGIN@6
1 | 1 | 1 | 8µs | 66µs | HTTP::Body::UrlEncoded::::BEGIN@7HTTP::Body::UrlEncoded::BEGIN@7
1 | 1 | 1 | 6µs | 7µs | HTTP::Body::UrlEncoded::::BEGIN@8HTTP::Body::UrlEncoded::BEGIN@8
1 | 1 | 1 | 2µs | 2µs | HTTP::Body::UrlEncoded::::CORE:qrHTTP::Body::UrlEncoded::CORE:qr (opcode)
0 | 0 | 0 | 0s | 0s | HTTP::Body::UrlEncoded::::spinHTTP::Body::UrlEncoded::spin

Call graph for these subroutines as a Graphviz dot language file.

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package HTTP::Body::UrlEncoded;
2 |  |  |  |  | {
3 | 2 | 800ns |  |  | $HTTP::Body::UrlEncoded::VERSION = '1.19';
4 |  |  |  |  | }
5 |  |  |  |  |
6 | 2 | 23µs | 2 | 37µs | # spent 24µs (12+12) within HTTP::Body::UrlEncoded::BEGIN@6 which was called: # once (12µs+12µs) by Plack::Request::BEGIN@10 at line 6 use strict; # spent 24µs making 1 call to HTTP::Body::UrlEncoded::BEGIN@6 # spent 12µs making 1 call to strict::import
7 | 2 | 23µs | 2 | 123µs | # spent 66µs (8+58) within HTTP::Body::UrlEncoded::BEGIN@7 which was called: # once (8µs+58µs) by Plack::Request::BEGIN@10 at line 7 use base 'HTTP::Body'; # spent 66µs making 1 call to HTTP::Body::UrlEncoded::BEGIN@7 # spent 58µs making 1 call to base::import
8 | 2 | 217µs | 2 | 8µs | # spent 7µs (6+1) within HTTP::Body::UrlEncoded::BEGIN@8 which was called: # once (6µs+1µs) by Plack::Request::BEGIN@10 at line 8 use bytes; # spent 7µs making 1 call to HTTP::Body::UrlEncoded::BEGIN@8 # spent 1µs making 1 call to bytes::import
9 |  |  |  |  |
10 | 1 | 8µs | 1 | 2µs | our $DECODE = qr/%([0-9a-fA-F]{2})/; # spent 2µs making 1 call to HTTP::Body::UrlEncoded::CORE:qr
11 |  |  |  |  |
12 | 1 | 100ns |  |  | our %hex_chr;
13 |  |  |  |  |
14 | 1 | 1µs |  |  | for my $num ( 0 .. 255 ) {
15 | 256 | 60µs |  |  | my $h = sprintf "%02X", $num;
16 | 256 | 245µs |  |  | $hex_chr{ lc $h } = $hex_chr{ uc $h } = chr $num;
17 |  |  |  |  | }
18 |  |  |  |  |
19 |  |  |  |  | =head1 NAME
20 |  |  |  |  |
21 |  |  |  |  | HTTP::Body::UrlEncoded - HTTP Body UrlEncoded Parser
22 |  |  |  |  |
23 |  |  |  |  | =head1 SYNOPSIS
24 |  |  |  |  |
25 |  |  |  |  | use HTTP::Body::UrlEncoded;
26 |  |  |  |  |
27 |  |  |  |  | =head1 DESCRIPTION
28 |  |  |  |  |
29 |  |  |  |  | HTTP Body UrlEncoded Parser.
30 |  |  |  |  |
31 |  |  |  |  | =head1 METHODS
32 |  |  |  |  |
33 |  |  |  |  | =over 4
34 |  |  |  |  |
35 |  |  |  |  | =item spin
36 |  |  |  |  |
37 |  |  |  |  | =cut
38 |  |  |  |  |
39 |  |  |  |  | sub spin {
40 |  |  |  |  | my $self = shift;
41 |  |  |  |  |
42 |  |  |  |  | return unless $self->length == $self->content_length;
43 |  |  |  |  |
44 |  |  |  |  | # I tested parsing this using APR::Request, but perl is faster
45 |  |  |  |  | # Pure-Perl 2560/s
46 |  |  |  |  | # APR::Request 2305/s
47 |  |  |  |  |
48 |  |  |  |  | # Note: s/// appears faster than tr///
49 |  |  |  |  | $self->{buffer} =~ s/\+/ /g;
50 |  |  |  |  |
51 |  |  |  |  | for my $pair ( split( /[&;](?:\s+)?/, $self->{buffer} ) ) {
52 |  |  |  |  |
53 |  |  |  |  | my ( $name, $value ) = split( /=/, $pair , 2 );
54 |  |  |  |  |
55 |  |  |  |  | next unless defined $name;
56 |  |  |  |  | next unless defined $value;
57 |  |  |  |  |
58 |  |  |  |  | $name =~ s/$DECODE/$hex_chr{$1}/gs;
59 |  |  |  |  | $value =~ s/$DECODE/$hex_chr{$1}/gs;
60 |  |  |  |  |
61 |  |  |  |  | $self->param( $name, $value );
62 |  |  |  |  | }
63 |  |  |  |  |
64 |  |  |  |  | $self->{buffer} = '';
65 |  |  |  |  | $self->{state} = 'done';
66 |  |  |  |  | }
67 |  |  |  |  |
68 |  |  |  |  | =back
69 |  |  |  |  |
70 |  |  |  |  | =head1 AUTHORS
71 |  |  |  |  |
72 |  |  |  |  | Christian Hansen, C<ch@ngmedia.com>
73 |  |  |  |  |
74 |  |  |  |  | Andy Grundman, C<andy@hybridized.org>
75 |  |  |  |  |
76 |  |  |  |  | =head1 LICENSE
77 |  |  |  |  |
78 |  |  |  |  | This library is free software . You can redistribute it and/or modify
79 |  |  |  |  | it under the same terms as perl itself.
80 |  |  |  |  |
81 |  |  |  |  | =cut
82 |  |  |  |  |
83 | 1 | 4µs |  |  | 1;
|  |  |  |  | # spent 2µs within HTTP::Body::UrlEncoded::CORE:qr which was called: # once (2µs+0s) by Plack::Request::BEGIN@10 at line 10 sub HTTP::Body::UrlEncoded::CORE:qr; # opcode