Filename | /home/micha/.plenv/versions/5.38.2/lib/perl5/site_perl/5.38.2/Test2/Hub/Interceptor.pm |
Statements | Executed 14 statements in 464µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 95µs | 124µs | BEGIN@8 | Test2::Hub::Interceptor::
1 | 1 | 1 | 12µs | 12µs | BEGIN@10 | Test2::Hub::Interceptor::
1 | 1 | 1 | 10µs | 11µs | BEGIN@2 | Test2::Hub::Interceptor::
1 | 1 | 1 | 5µs | 18µs | BEGIN@93 | Test2::Hub::Interceptor::
1 | 1 | 1 | 4µs | 45µs | BEGIN@11 | Test2::Hub::Interceptor::
1 | 1 | 1 | 3µs | 20µs | BEGIN@3 | Test2::Hub::Interceptor::
0 | 0 | 0 | 0s | 0s | clean_inherited | Test2::Hub::Interceptor::
0 | 0 | 0 | 0s | 0s | inherit | Test2::Hub::Interceptor::
0 | 0 | 0 | 0s | 0s | init | Test2::Hub::Interceptor::
0 | 0 | 0 | 0s | 0s | restore_inherited | Test2::Hub::Interceptor::
0 | 0 | 0 | 0s | 0s | terminate | Test2::Hub::Interceptor::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Test2::Hub::Interceptor; | ||||
2 | 2 | 19µs | 2 | 13µs | # spent 11µs (10+2) within Test2::Hub::Interceptor::BEGIN@2 which was called:
# once (10µs+2µs) by Test2::API::BEGIN@89 at line 2 # spent 11µs making 1 call to Test2::Hub::Interceptor::BEGIN@2
# spent 2µs making 1 call to strict::import |
3 | 2 | 27µs | 2 | 36µs | # spent 20µs (3+16) within Test2::Hub::Interceptor::BEGIN@3 which was called:
# once (3µs+16µs) by Test2::API::BEGIN@89 at line 3 # spent 20µs making 1 call to Test2::Hub::Interceptor::BEGIN@3
# spent 16µs making 1 call to warnings::import |
4 | |||||
5 | 1 | 300ns | our $VERSION = '1.302198'; | ||
6 | |||||
7 | |||||
8 | 2 | 79µs | 1 | 124µs | # spent 124µs (95+30) within Test2::Hub::Interceptor::BEGIN@8 which was called:
# once (95µs+30µs) by Test2::API::BEGIN@89 at line 8 # spent 124µs making 1 call to Test2::Hub::Interceptor::BEGIN@8 |
9 | |||||
10 | 2 | 26µs | 1 | 12µs | # spent 12µs within Test2::Hub::Interceptor::BEGIN@10 which was called:
# once (12µs+0s) by Test2::API::BEGIN@89 at line 10 # spent 12µs making 1 call to Test2::Hub::Interceptor::BEGIN@10 |
11 | 2 | 265µs | 2 | 86µs | # spent 45µs (4+41) within Test2::Hub::Interceptor::BEGIN@11 which was called:
# once (4µs+41µs) by Test2::API::BEGIN@89 at line 11 # spent 45µs making 1 call to Test2::Hub::Interceptor::BEGIN@11
# spent 41µs making 1 call to Test2::Util::HashBase::import |
12 | |||||
13 | sub init { | ||||
14 | my $self = shift; | ||||
15 | $self->SUPER::init(); | ||||
16 | $self->{+NESTED} = 0; | ||||
17 | } | ||||
18 | |||||
19 | sub inherit { | ||||
20 | my $self = shift; | ||||
21 | my ($from, %params) = @_; | ||||
22 | |||||
23 | $self->{+NESTED} = 0; | ||||
24 | |||||
25 | if ($from->{+IPC} && !$self->{+IPC} && !exists($params{ipc})) { | ||||
26 | my $ipc = $from->{+IPC}; | ||||
27 | $self->{+IPC} = $ipc; | ||||
28 | $ipc->add_hub($self->{+HID}); | ||||
29 | } | ||||
30 | |||||
31 | if (my $ls = $from->{+_LISTENERS}) { | ||||
32 | push @{$self->{+_LISTENERS}} => grep { $_->{intercept_inherit} } @$ls; | ||||
33 | } | ||||
34 | |||||
35 | if (my $pfs = $from->{+_PRE_FILTERS}) { | ||||
36 | push @{$self->{+_PRE_FILTERS}} => grep { $_->{intercept_inherit} } @$pfs; | ||||
37 | } | ||||
38 | |||||
39 | if (my $fs = $from->{+_FILTERS}) { | ||||
40 | push @{$self->{+_FILTERS}} => grep { $_->{intercept_inherit} } @$fs; | ||||
41 | } | ||||
42 | } | ||||
43 | |||||
44 | sub clean_inherited { | ||||
45 | my $self = shift; | ||||
46 | my %params = @_; | ||||
47 | |||||
48 | my @sets = ( | ||||
49 | $self->{+_LISTENERS}, | ||||
50 | $self->{+_PRE_FILTERS}, | ||||
51 | $self->{+_FILTERS}, | ||||
52 | ); | ||||
53 | |||||
54 | for my $set (@sets) { | ||||
55 | next unless $set; | ||||
56 | |||||
57 | for my $i (@$set) { | ||||
58 | my $cbs = $i->{intercept_inherit} or next; | ||||
59 | next unless ref($cbs) eq 'HASH'; | ||||
60 | my $cb = $cbs->{clean} or next; | ||||
61 | $cb->(%params); | ||||
62 | } | ||||
63 | } | ||||
64 | } | ||||
65 | |||||
66 | sub restore_inherited { | ||||
67 | my $self = shift; | ||||
68 | my %params = @_; | ||||
69 | |||||
70 | my @sets = ( | ||||
71 | $self->{+_FILTERS}, | ||||
72 | $self->{+_PRE_FILTERS}, | ||||
73 | $self->{+_LISTENERS}, | ||||
74 | ); | ||||
75 | |||||
76 | for my $set (@sets) { | ||||
77 | next unless $set; | ||||
78 | |||||
79 | for my $i (@$set) { | ||||
80 | my $cbs = $i->{intercept_inherit} or next; | ||||
81 | next unless ref($cbs) eq 'HASH'; | ||||
82 | my $cb = $cbs->{restore} or next; | ||||
83 | $cb->(%params); | ||||
84 | } | ||||
85 | } | ||||
86 | } | ||||
87 | |||||
88 | sub terminate { | ||||
89 | my $self = shift; | ||||
90 | my ($code) = @_; | ||||
91 | |||||
92 | eval { | ||||
93 | 2 | 46µs | 2 | 32µs | # spent 18µs (5+14) within Test2::Hub::Interceptor::BEGIN@93 which was called:
# once (5µs+14µs) by Test2::API::BEGIN@89 at line 93 # spent 18µs making 1 call to Test2::Hub::Interceptor::BEGIN@93
# spent 14µs making 1 call to warnings::unimport |
94 | last T2_SUBTEST_WRAPPER; | ||||
95 | }; | ||||
96 | my $err = $@; | ||||
97 | |||||
98 | # Fallback | ||||
99 | die bless(\$err, 'Test2::Hub::Interceptor::Terminator'); | ||||
100 | } | ||||
101 | |||||
102 | 1 | 2µs | 1; | ||
103 | |||||
104 | __END__ |