Filename | /usr/local/perls/perl-5.26.1/lib/site_perl/5.26.1/URI/WithBase.pm |
Statements | Executed 34 statements in 1.49ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 6.15ms | 9.17ms | BEGIN@6 | URI::WithBase::
4 | 1 | 1 | 34µs | 3.82ms | AUTOLOAD | URI::WithBase::
1 | 1 | 1 | 31µs | 35µs | BEGIN@3 | URI::WithBase::
1 | 1 | 1 | 24µs | 108µs | BEGIN@7 | URI::WithBase::
2 | 1 | 1 | 22µs | 8.90ms | new | URI::WithBase::
1 | 1 | 1 | 18µs | 31µs | BEGIN@4 | URI::WithBase::
1 | 1 | 1 | 14µs | 55µs | BEGIN@11 | URI::WithBase::
0 | 0 | 0 | 0s | 0s | _init | URI::WithBase::
0 | 0 | 0 | 0s | 0s | abs | URI::WithBase::
0 | 0 | 0 | 0s | 0s | base | URI::WithBase::
0 | 0 | 0 | 0s | 0s | can | URI::WithBase::
0 | 0 | 0 | 0s | 0s | clone | URI::WithBase::
0 | 0 | 0 | 0s | 0s | eq | URI::WithBase::
0 | 0 | 0 | 0s | 0s | new_abs | URI::WithBase::
0 | 0 | 0 | 0s | 0s | rel | URI::WithBase::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package URI::WithBase; | ||||
2 | |||||
3 | 2 | 42µs | 2 | 39µs | # spent 35µs (31+4) within URI::WithBase::BEGIN@3 which was called:
# once (31µs+4µs) by parent::import at line 3 # spent 35µs making 1 call to URI::WithBase::BEGIN@3
# spent 4µs making 1 call to strict::import |
4 | 2 | 42µs | 2 | 44µs | # spent 31µs (18+13) within URI::WithBase::BEGIN@4 which was called:
# once (18µs+13µs) by parent::import at line 4 # spent 31µs making 1 call to URI::WithBase::BEGIN@4
# spent 13µs making 1 call to warnings::import |
5 | |||||
6 | 2 | 578µs | 1 | 9.17ms | # spent 9.17ms (6.15+3.02) within URI::WithBase::BEGIN@6 which was called:
# once (6.15ms+3.02ms) by parent::import at line 6 # spent 9.17ms making 1 call to URI::WithBase::BEGIN@6 |
7 | 2 | 64µs | 2 | 192µs | # spent 108µs (24+84) within URI::WithBase::BEGIN@7 which was called:
# once (24µs+84µs) by parent::import at line 7 # spent 108µs making 1 call to URI::WithBase::BEGIN@7
# spent 84µs making 1 call to Exporter::import |
8 | |||||
9 | 1 | 1µs | our $VERSION = "2.20"; | ||
10 | |||||
11 | 2 | 696µs | 2 | 96µs | # spent 55µs (14+41) within URI::WithBase::BEGIN@11 which was called:
# once (14µs+41µs) by parent::import at line 11 # spent 55µs making 1 call to URI::WithBase::BEGIN@11
# spent 41µs making 1 call to overload::import |
12 | |||||
13 | sub as_string; # help overload find it | ||||
14 | |||||
15 | sub new | ||||
16 | # spent 8.90ms (22µs+8.88) within URI::WithBase::new which was called 2 times, avg 4.45ms/call:
# 2 times (22µs+8.88ms) by URI::URL::new at line 24 of URI/URL.pm, avg 4.45ms/call | ||||
17 | 2 | 3µs | my($class, $uri, $base) = @_; | ||
18 | 2 | 0s | my $ibase = $base; | ||
19 | 2 | 2µs | if ($base && blessed($base) && $base->isa(__PACKAGE__)) { | ||
20 | $base = $base->abs; | ||||
21 | $ibase = $base->[0]; | ||||
22 | } | ||||
23 | 2 | 23µs | 2 | 8.88ms | bless [URI->new($uri, $ibase), $base], $class; # spent 8.88ms making 2 calls to URI::new, avg 4.44ms/call |
24 | } | ||||
25 | |||||
26 | sub new_abs | ||||
27 | { | ||||
28 | my $class = shift; | ||||
29 | my $self = $class->new(@_); | ||||
30 | $self->abs; | ||||
31 | } | ||||
32 | |||||
33 | sub _init | ||||
34 | { | ||||
35 | my $class = shift; | ||||
36 | my($str, $scheme) = @_; | ||||
37 | bless [URI->new($str, $scheme), undef], $class; | ||||
38 | } | ||||
39 | |||||
40 | sub eq | ||||
41 | { | ||||
42 | my($self, $other) = @_; | ||||
43 | $other = $other->[0] if blessed($other) and $other->isa(__PACKAGE__); | ||||
44 | $self->[0]->eq($other); | ||||
45 | } | ||||
46 | |||||
47 | our $AUTOLOAD; | ||||
48 | sub AUTOLOAD | ||||
49 | # spent 3.82ms (34µs+3.78) within URI::WithBase::AUTOLOAD which was called 4 times, avg 955µs/call:
# 4 times (34µs+3.78ms) by CPAN::FTP::hostdleasy at line 564 of CPAN/FTP.pm, avg 955µs/call | ||||
50 | 4 | 2µs | my $self = shift; | ||
51 | 4 | 10µs | my $method = substr($AUTOLOAD, rindex($AUTOLOAD, '::')+2); | ||
52 | 4 | 6µs | return if $method eq "DESTROY"; | ||
53 | 2 | 15µs | 2 | 3.79ms | $self->[0]->$method(@_); # spent 3.79ms making 2 calls to URI::file::file, avg 1.89ms/call |
54 | } | ||||
55 | |||||
56 | sub can { # override UNIVERSAL::can | ||||
57 | my $self = shift; | ||||
58 | $self->SUPER::can(@_) || ( | ||||
59 | ref($self) | ||||
60 | ? $self->[0]->can(@_) | ||||
61 | : undef | ||||
62 | ) | ||||
63 | } | ||||
64 | |||||
65 | sub base { | ||||
66 | my $self = shift; | ||||
67 | my $base = $self->[1]; | ||||
68 | |||||
69 | if (@_) { # set | ||||
70 | my $new_base = shift; | ||||
71 | # ensure absoluteness | ||||
72 | $new_base = $new_base->abs if ref($new_base) && $new_base->isa(__PACKAGE__); | ||||
73 | $self->[1] = $new_base; | ||||
74 | } | ||||
75 | return unless defined wantarray; | ||||
76 | |||||
77 | # The base attribute supports 'lazy' conversion from URL strings | ||||
78 | # to URL objects. Strings may be stored but when a string is | ||||
79 | # fetched it will automatically be converted to a URL object. | ||||
80 | # The main benefit is to make it much cheaper to say: | ||||
81 | # URI::WithBase->new($random_url_string, 'http:') | ||||
82 | if (defined($base) && !ref($base)) { | ||||
83 | $base = ref($self)->new($base); | ||||
84 | $self->[1] = $base unless @_; | ||||
85 | } | ||||
86 | $base; | ||||
87 | } | ||||
88 | |||||
89 | sub clone | ||||
90 | { | ||||
91 | my $self = shift; | ||||
92 | my $base = $self->[1]; | ||||
93 | $base = $base->clone if ref($base); | ||||
94 | bless [$self->[0]->clone, $base], ref($self); | ||||
95 | } | ||||
96 | |||||
97 | sub abs | ||||
98 | { | ||||
99 | my $self = shift; | ||||
100 | my $base = shift || $self->base || return $self->clone; | ||||
101 | $base = $base->as_string if ref($base); | ||||
102 | bless [$self->[0]->abs($base, @_), $base], ref($self); | ||||
103 | } | ||||
104 | |||||
105 | sub rel | ||||
106 | { | ||||
107 | my $self = shift; | ||||
108 | my $base = shift || $self->base || return $self->clone; | ||||
109 | $base = $base->as_string if ref($base); | ||||
110 | bless [$self->[0]->rel($base, @_), $base], ref($self); | ||||
111 | } | ||||
112 | |||||
113 | 1 | 4µs | 1; | ||
114 | |||||
115 | __END__ |