← 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:12 2016

Filename/usr/local/share/perl/5.18.2/HTTP/Headers/Util.pm
StatementsExecuted 1100020 statements in 3.35s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
100001112.73s3.14sHTTP::Headers::Util::::_split_header_wordsHTTP::Headers::Util::_split_header_words
30000321417ms417msHTTP::Headers::Util::::CORE:substHTTP::Headers::Util::CORE:subst (opcode)
11114µs33µsHTTP::Headers::Util::::BEGIN@3HTTP::Headers::Util::BEGIN@3
11110µs96µsHTTP::Headers::Util::::BEGIN@8HTTP::Headers::Util::BEGIN@8
1119µs18µsHTTP::Headers::Util::::BEGIN@4HTTP::Headers::Util::BEGIN@4
0000s0sHTTP::Headers::Util::::join_header_wordsHTTP::Headers::Util::join_header_words
0000s0sHTTP::Headers::Util::::split_header_wordsHTTP::Headers::Util::split_header_words
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package HTTP::Headers::Util;
2
3228µs252µs
# spent 33µs (14+19) within HTTP::Headers::Util::BEGIN@3 which was called: # once (14µs+19µs) by HTTP::Headers::ActionPack::Util::BEGIN@15 at line 3
use strict;
# spent 33µs making 1 call to HTTP::Headers::Util::BEGIN@3 # spent 19µs making 1 call to strict::import
4241µs227µs
# spent 18µs (9+9) within HTTP::Headers::Util::BEGIN@4 which was called: # once (9µs+9µs) by HTTP::Headers::ActionPack::Util::BEGIN@15 at line 4
use warnings;
# spent 18µs making 1 call to HTTP::Headers::Util::BEGIN@4 # spent 9µs making 1 call to warnings::import
5
61500nsour $VERSION = "6.11";
7
82602µs2183µs
# spent 96µs (10+86) within HTTP::Headers::Util::BEGIN@8 which was called: # once (10µs+86µs) by HTTP::Headers::ActionPack::Util::BEGIN@15 at line 8
use base 'Exporter';
# spent 96µs making 1 call to HTTP::Headers::Util::BEGIN@8 # spent 86µs making 1 call to base::import
9
1011µsour @EXPORT_OK=qw(split_header_words _split_header_words join_header_words);
11
12
13sub split_header_words {
14 my @res = &_split_header_words;
15 for my $arr (@res) {
16 for (my $i = @$arr - 2; $i >= 0; $i -= 2) {
17 $arr->[$i] = lc($arr->[$i]);
18 }
19 }
20 return @res;
21}
22
23sub _split_header_words
24
# spent 3.14s (2.73+417ms) within HTTP::Headers::Util::_split_header_words which was called 100001 times, avg 31µs/call: # 100001 times (2.73s+417ms) by HTTP::Headers::ActionPack::Util::split_header_words at line 33 of HTTP/Headers/ActionPack/Util.pm, avg 31µs/call
{
25100001111ms my(@val) = @_;
2610000156.6ms my @res;
27100001134ms for (@val) {
2810000126.4ms my @cur;
29100001107ms while (length) {
30100001880ms100001321ms if (s/^\s*(=*[^\s=;,]+)//) { # 'token' or parameter 'attribute'
# spent 321ms making 100001 calls to HTTP::Headers::Util::CORE:subst, avg 3µs/call
31100001424ms push(@cur, $1);
32 # a quoted value
33100001843ms20000295.5ms if (s/^\s*=\s*\"([^\"\\]*(?:\\.[^\"\\]*)*)\"//) {
# spent 95.5ms making 200002 calls to HTTP::Headers::Util::CORE:subst, avg 478ns/call
34 my $val = $1;
35 $val =~ s/\\(.)/$1/g;
36 push(@cur, $val);
37 # some unquoted value
38 }
39 elsif (s/^\s*=\s*([^;,\s]*)//) {
40 my $val = $1;
41 $val =~ s/\s+$//;
42 push(@cur, $val);
43 # no value, a lone token
44 }
45 else {
4610000157.8ms push(@cur, undef);
47 }
48 }
49 elsif (s/^\s*,//) {
50 push(@res, [@cur]) if @cur;
51 @cur = ();
52 }
53 elsif (s/^\s*;// || s/^\s+//) {
54 # continue
55 }
56 else {
57 die "This should not happen: '$_'";
58 }
59 }
60100001183ms push(@res, \@cur) if @cur;
61 }
62100001529ms @res;
63}
64
65
66sub join_header_words
67{
68 @_ = ([@_]) if @_ && !ref($_[0]);
69 my @res;
70 for (@_) {
71 my @cur = @$_;
72 my @attr;
73 while (@cur) {
74 my $k = shift @cur;
75 my $v = shift @cur;
76 if (defined $v) {
77 if ($v =~ /[\x00-\x20()<>@,;:\\\"\/\[\]?={}\x7F-\xFF]/ || !length($v)) {
78 $v =~ s/([\"\\])/\\$1/g; # escape " and \
79 $k .= qq(="$v");
80 }
81 else {
82 # token
83 $k .= "=$v";
84 }
85 }
86 push(@attr, $k);
87 }
88 push(@res, join("; ", @attr)) if @attr;
89 }
90 join(", ", @res);
91}
92
93
9414µs1;
95
96__END__
 
# spent 417ms within HTTP::Headers::Util::CORE:subst which was called 300003 times, avg 1µs/call: # 200002 times (95.5ms+0s) by HTTP::Headers::Util::_split_header_words at line 33, avg 478ns/call # 100001 times (321ms+0s) by HTTP::Headers::Util::_split_header_words at line 30, avg 3µs/call
sub HTTP::Headers::Util::CORE:subst; # opcode