Filename | /home/micha/.plenv/versions/5.38.2/lib/perl5/site_perl/5.38.2/Test2/Util/HashBase.pm |
Statements | Executed 2336 statements in 3.26ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
31 | 31 | 31 | 2.14ms | 2.22ms | import | Test2::Util::HashBase::
1 | 1 | 1 | 208µs | 355µs | BEGIN@33 | Test2::Util::HashBase::
10 | 10 | 7 | 56µs | 226µs | _new (recurses: max depth 1, inclusive time 4µs) | Test2::Util::HashBase::
49 | 42 | 5 | 38µs | 38µs | __ANON__[:84] | Test2::Util::HashBase::
1 | 1 | 1 | 9µs | 11µs | BEGIN@2 | Test2::Util::HashBase::
1 | 1 | 1 | 7µs | 12µs | BEGIN@94 | Test2::Util::HashBase::
1 | 1 | 1 | 5µs | 9µs | BEGIN@37 | Test2::Util::HashBase::
1 | 1 | 1 | 4µs | 15µs | BEGIN@18 | Test2::Util::HashBase::
1 | 1 | 1 | 4µs | 14µs | BEGIN@29 | Test2::Util::HashBase::
1 | 1 | 1 | 3µs | 18µs | BEGIN@3 | Test2::Util::HashBase::
2 | 2 | 1 | 2µs | 2µs | __ANON__[:85] | Test2::Util::HashBase::
0 | 0 | 0 | 0s | 0s | __ANON__[:44] | Test2::Util::HashBase::
0 | 0 | 0 | 0s | 0s | __ANON__[:81] | Test2::Util::HashBase::
0 | 0 | 0 | 0s | 0s | __ANON__[:86] | Test2::Util::HashBase::
0 | 0 | 0 | 0s | 0s | __ANON__[:87] | Test2::Util::HashBase::
0 | 0 | 0 | 0s | 0s | attr_list | Test2::Util::HashBase::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Test2::Util::HashBase; | ||||
2 | 2 | 17µs | 2 | 12µs | # spent 11µs (9+1) within Test2::Util::HashBase::BEGIN@2 which was called:
# once (9µs+1µs) by Test2::EventFacet::BEGIN@7 at line 2 # spent 11µs making 1 call to Test2::Util::HashBase::BEGIN@2
# spent 2µs making 1 call to strict::import |
3 | 2 | 30µs | 2 | 33µs | # spent 18µs (3+15) within Test2::Util::HashBase::BEGIN@3 which was called:
# once (3µs+15µs) by Test2::EventFacet::BEGIN@7 at line 3 # spent 18µs making 1 call to Test2::Util::HashBase::BEGIN@3
# spent 15µs making 1 call to warnings::import |
4 | |||||
5 | 1 | 400ns | our $VERSION = '1.302198'; | ||
6 | |||||
7 | ################################################################# | ||||
8 | # # | ||||
9 | # This is a generated file! Do not modify this file directly! # | ||||
10 | # Use hashbase_inc.pl script to regenerate this file. # | ||||
11 | # The script is part of the Object::HashBase distribution. # | ||||
12 | # Note: You can modify the version number above this comment # | ||||
13 | # if needed, that is fine. # | ||||
14 | # # | ||||
15 | ################################################################# | ||||
16 | |||||
17 | { | ||||
18 | 3 | 52µs | 2 | 25µs | # spent 15µs (4+11) within Test2::Util::HashBase::BEGIN@18 which was called:
# once (4µs+11µs) by Test2::EventFacet::BEGIN@7 at line 18 # spent 15µs making 1 call to Test2::Util::HashBase::BEGIN@18
# spent 11µs making 1 call to warnings::unimport |
19 | 1 | 100ns | $Test2::Util::HashBase::HB_VERSION = '0.009'; | ||
20 | 1 | 1µs | *Test2::Util::HashBase::ATTR_SUBS = \%Object::HashBase::ATTR_SUBS; | ||
21 | 1 | 100ns | *Test2::Util::HashBase::ATTR_LIST = \%Object::HashBase::ATTR_LIST; | ||
22 | 1 | 200ns | *Test2::Util::HashBase::VERSION = \%Object::HashBase::VERSION; | ||
23 | 1 | 300ns | *Test2::Util::HashBase::CAN_CACHE = \%Object::HashBase::CAN_CACHE; | ||
24 | } | ||||
25 | |||||
26 | |||||
27 | 1 | 400ns | require Carp; | ||
28 | { | ||||
29 | 3 | 42µs | 2 | 24µs | # spent 14µs (4+10) within Test2::Util::HashBase::BEGIN@29 which was called:
# once (4µs+10µs) by Test2::EventFacet::BEGIN@7 at line 29 # spent 14µs making 1 call to Test2::Util::HashBase::BEGIN@29
# spent 10µs making 1 call to warnings::unimport |
30 | 1 | 500ns | $Carp::Internal{+__PACKAGE__} = 1; | ||
31 | } | ||||
32 | |||||
33 | # spent 355µs (208+146) within Test2::Util::HashBase::BEGIN@33 which was called:
# once (208µs+146µs) by Test2::EventFacet::BEGIN@7 at line 45 | ||||
34 | # these are not strictly equivalent, but for out use we don't care | ||||
35 | # about order | ||||
36 | *_isa = ($] >= 5.010 && require mro) ? \&mro::get_linear_isa : sub { | ||||
37 | 2 | 69µs | 2 | 13µs | # spent 9µs (5+4) within Test2::Util::HashBase::BEGIN@37 which was called:
# once (5µs+4µs) by Test2::EventFacet::BEGIN@7 at line 37 # spent 9µs making 1 call to Test2::Util::HashBase::BEGIN@37
# spent 4µs making 1 call to strict::unimport |
38 | my @packages = ($_[0]); | ||||
39 | my %seen; | ||||
40 | for my $package (@packages) { | ||||
41 | push @packages, grep !$seen{$_}++, @{"$package\::ISA"}; | ||||
42 | } | ||||
43 | return \@packages; | ||||
44 | } | ||||
45 | 1 | 336µs | 1 | 355µs | } # spent 355µs making 1 call to Test2::Util::HashBase::BEGIN@33 |
46 | |||||
47 | 1 | 4µs | my %SPEC = ( | ||
48 | '^' => {reader => 1, writer => 0, dep_writer => 1, read_only => 0, strip => 1}, | ||||
49 | '-' => {reader => 1, writer => 0, dep_writer => 0, read_only => 1, strip => 1}, | ||||
50 | '>' => {reader => 0, writer => 1, dep_writer => 0, read_only => 0, strip => 1}, | ||||
51 | '<' => {reader => 1, writer => 0, dep_writer => 0, read_only => 0, strip => 1}, | ||||
52 | '+' => {reader => 0, writer => 0, dep_writer => 0, read_only => 0, strip => 1}, | ||||
53 | ); | ||||
54 | |||||
55 | # spent 2.22ms (2.14+78µs) within Test2::Util::HashBase::import which was called 31 times, avg 71µs/call:
# once (291µs+4µs) by Test2::Hub::BEGIN@15 at line 15 of Test2/Hub.pm
# once (222µs+3µs) by Test2::API::Instance::BEGIN@16 at line 16 of Test2/API/Instance.pm
# once (125µs+3µs) by Test2::API::Context::BEGIN@26 at line 26 of Test2/API/Context.pm
# once (110µs+2µs) by Test2::EventFacet::Trace::BEGIN@13 at line 13 of Test2/EventFacet/Trace.pm
# once (89µs+2µs) by Test2::EventFacet::Hub::BEGIN@11 at line 11 of Test2/EventFacet/Hub.pm
# once (89µs+2µs) by Test2::Event::Subtest::BEGIN@8 at line 8 of Test2/Event/Subtest.pm
# once (70µs+2µs) by Test2::Hub::Subtest::BEGIN@8 at line 8 of Test2/Hub/Subtest.pm
# once (69µs+3µs) by Test2::Formatter::TAP::BEGIN@9 at line 9 of Test2/Formatter/TAP.pm
# once (69µs+2µs) by Test2::EventFacet::Parent::BEGIN@10 at line 10 of Test2/EventFacet/Parent.pm
# once (68µs+2µs) by Test2::EventFacet::Control::BEGIN@8 at line 8 of Test2/EventFacet/Control.pm
# once (64µs+3µs) by Test2::Event::BEGIN@10 at line 10 of Test2/Event.pm
# once (62µs+2µs) by Test2::EventFacet::Plan::BEGIN@8 at line 8 of Test2/EventFacet/Plan.pm
# once (56µs+3µs) by Test2::Event::Ok::BEGIN@9 at line 9 of Test2/Event/Ok.pm
# once (54µs+2µs) by Test2::EventFacet::Info::BEGIN@10 at line 10 of Test2/EventFacet/Info.pm
# once (50µs+4µs) by Test2::Event::Exception::BEGIN@9 at line 9 of Test2/Event/Exception.pm
# once (51µs+2µs) by Test2::Event::Fail::BEGIN@15 at line 15 of Test2/Event/Fail.pm
# once (51µs+2µs) by Test2::EventFacet::About::BEGIN@8 at line 8 of Test2/EventFacet/About.pm
# once (51µs+2µs) by Test2::Event::Pass::BEGIN@15 at line 15 of Test2/Event/Pass.pm
# once (47µs+2µs) by Test2::Event::Plan::BEGIN@9 at line 9 of Test2/Event/Plan.pm
# once (46µs+2µs) by Test2::Event::Bail::BEGIN@9 at line 9 of Test2/Event/Bail.pm
# once (43µs+3µs) by Test::Builder::Formatter::BEGIN@9 at line 9 of Test/Builder/Formatter.pm
# once (44µs+2µs) by Test2::EventFacet::Error::BEGIN@11 at line 11 of Test2/EventFacet/Error.pm
# once (43µs+2µs) by Test2::EventFacet::Assert::BEGIN@8 at line 8 of Test2/EventFacet/Assert.pm
# once (40µs+2µs) by Test2::Event::Skip::BEGIN@9 at line 9 of Test2/Event/Skip.pm
# once (39µs+2µs) by Test2::Hub::Interceptor::BEGIN@11 at line 11 of Test2/Hub/Interceptor.pm
# once (35µs+5µs) by Test2::EventFacet::BEGIN@7 at line 7 of Test2/EventFacet.pm
# once (38µs+2µs) by Test2::Event::Diag::BEGIN@9 at line 9 of Test2/Event/Diag.pm
# once (37µs+2µs) by Test2::EventFacet::Amnesty::BEGIN@10 at line 10 of Test2/EventFacet/Amnesty.pm
# once (35µs+2µs) by Test2::Event::Note::BEGIN@9 at line 9 of Test2/Event/Note.pm
# once (32µs+3µs) by Test2::Event::V2::BEGIN@17 at line 17 of Test2/Event/V2.pm
# once (19µs+2µs) by Test2::Event::Waiting::BEGIN@9 at line 9 of Test2/Event/Waiting.pm | ||||
56 | 31 | 9µs | my $class = shift; | ||
57 | 31 | 12µs | my $into = caller; | ||
58 | |||||
59 | # Make sure we list the OLDEST version used to create this class. | ||||
60 | 31 | 8µs | my $ver = $Test2::Util::HashBase::HB_VERSION || $Test2::Util::HashBase::VERSION; | ||
61 | 31 | 28µs | $Test2::Util::HashBase::VERSION{$into} = $ver if !$Test2::Util::HashBase::VERSION{$into} || $Test2::Util::HashBase::VERSION{$into} > $ver; | ||
62 | |||||
63 | 31 | 93µs | 31 | 34µs | my $isa = _isa($into); # spent 34µs making 31 calls to mro::get_linear_isa, avg 1µs/call |
64 | 31 | 15µs | my $attr_list = $Test2::Util::HashBase::ATTR_LIST{$into} ||= []; | ||
65 | 31 | 11µs | my $attr_subs = $Test2::Util::HashBase::ATTR_SUBS{$into} ||= {}; | ||
66 | |||||
67 | my %subs = ( | ||||
68 | ($into->can('new') ? () : (new => \&_new)), | ||||
69 | (map %{$Test2::Util::HashBase::ATTR_SUBS{$_} || {}}, @{$isa}[1 .. $#$isa]), | ||||
70 | ( | ||||
71 | map { | ||||
72 | 178 | 347µs | 31 | 44µs | my $p = substr($_, 0, 1); # spent 44µs making 31 calls to UNIVERSAL::can, avg 1µs/call |
73 | 147 | 15µs | my $x = $_; | ||
74 | |||||
75 | 147 | 55µs | my $spec = $SPEC{$p} || {reader => 1, writer => 1}; | ||
76 | |||||
77 | 147 | 29µs | substr($x, 0, 1) = '' if $spec->{strip}; | ||
78 | 147 | 42µs | push @$attr_list => $x; | ||
79 | 147 | 51µs | my ($sub, $attr) = (uc $x, $x); | ||
80 | |||||
81 | 147 | 289µs | $attr_subs->{$sub} = sub() { $attr }; | ||
82 | 147 | 50µs | my %out = ($sub => $attr_subs->{$sub}); | ||
83 | |||||
84 | 196 | 203µs | # spent 38µs within Test2::Util::HashBase::__ANON__[/home/micha/.plenv/versions/5.38.2/lib/perl5/site_perl/5.38.2/Test2/Util/HashBase.pm:84] which was called 49 times, avg 773ns/call:
# 4 times (4µs+0s) by Test2::API::test2_in_preload at line 207 of Test2/API.pm, avg 1µs/call
# 2 times (1µs+0s) by Test2::API::Instance::__ANON__[/home/micha/.plenv/versions/5.38.2/lib/perl5/site_perl/5.38.2/Test2/API/Instance.pm:60] at line 59 of Test2/API/Instance.pm, avg 700ns/call
# 2 times (1µs+0s) by Test::Builder::done_testing at line 598 of Test/Builder.pm, avg 550ns/call
# 2 times (900ns+0s) by Test::Builder::_ending at line 1656 of Test/Builder.pm, avg 450ns/call
# 2 times (600ns+0s) by Test::Builder::done_testing at line 618 of Test/Builder.pm, avg 300ns/call
# once (2µs+0s) by Test::Builder::reset at line 446 of Test/Builder.pm
# once (2µs+0s) by Test::Builder::done_testing at line 586 of Test/Builder.pm
# once (2µs+0s) by Test::Builder::BEGIN@18 at line 181 of Test2/API.pm
# once (1µs+0s) by Test2::API::_context_release_callbacks_ref at line 321 of Test2/API.pm
# once (1µs+0s) by Test::Builder::done_testing at line 595 of Test/Builder.pm
# once (1µs+0s) by Test2::Hub::finalize at line 446 of Test2/Hub.pm
# once (1µs+0s) by Test2::API::test2_set_is_end at line 30 of Test2/API.pm
# once (1µs+0s) by Test2::API::test2_init_done at line 201 of Test2/API.pm
# once (1µs+0s) by Test2::API::test2_stack at line 211 of Test2/API.pm
# once (1µs+0s) by Test2::API::Instance::set_exit at line 551 of Test2/API/Instance.pm
# once (1µs+0s) by Test::Builder::_ending at line 1664 of Test/Builder.pm
# once (1µs+0s) by Test2::API::Instance::set_exit at line 553 of Test2/API/Instance.pm
# once (800ns+0s) by Test::Builder::reset at line 455 of Test/Builder.pm
# once (800ns+0s) by Test2::Event::common_facet_data at line 137 of Test2/Event.pm
# once (800ns+0s) by Test2::Event::common_facet_data at line 131 of Test2/Event.pm
# once (700ns+0s) by Test2::API::test2_load_done at line 202 of Test2/API.pm
# once (700ns+0s) by Test2::Event::common_facet_data at line 141 of Test2/Event.pm
# once (600ns+0s) by Test::Builder::_ending at line 1668 of Test/Builder.pm
# once (600ns+0s) by Test::Builder::reset at line 470 of Test/Builder.pm
# once (500ns+0s) by Test::Builder::BEGIN@18 at line 183 of Test2/API.pm
# once (500ns+0s) by Test2::API::_contexts_ref at line 318 of Test2/API.pm
# once (500ns+0s) by Test::Builder::BEGIN@18 at line 182 of Test2/API.pm
# once (500ns+0s) by Test2::API::test2_set_is_end at line 33 of Test2/API.pm
# once (500ns+0s) by Test::Builder::use_numbers at line 1221 of Test/Builder.pm
# once (500ns+0s) by Test::Builder::_ending at line 1667 of Test/Builder.pm
# once (500ns+0s) by Test::Builder::current_test at line 1438 of Test/Builder.pm
# once (500ns+0s) by Test::Builder::reset_outputs at line 1410 of Test/Builder.pm
# once (400ns+0s) by Test::Builder::BEGIN@18 at line 184 of Test2/API.pm
# once (400ns+0s) by Test::Builder::expected_tests at line 551 of Test/Builder.pm
# once (400ns+0s) by Test::Builder::use_numbers at line 1229 of Test/Builder.pm
# once (400ns+0s) by Test::Builder::done_testing at line 597 of Test/Builder.pm
# once (400ns+0s) by Test::Builder::reset at line 468 of Test/Builder.pm
# once (300ns+0s) by Test2::API::Instance::set_exit at line 555 of Test2/API/Instance.pm
# once (300ns+0s) by Test::Builder::_ending at line 1657 of Test/Builder.pm
# once (300ns+0s) by Test::Builder::_ending at line 1663 of Test/Builder.pm
# once (300ns+0s) by Test::Builder::current_test at line 1464 of Test/Builder.pm
# once (300ns+0s) by Test::Builder::done_testing at line 616 of Test/Builder.pm | ||
85 | 149 | 192µs | # spent 2µs within Test2::Util::HashBase::__ANON__[/home/micha/.plenv/versions/5.38.2/lib/perl5/site_perl/5.38.2/Test2/Util/HashBase.pm:85] which was called 2 times, avg 950ns/call:
# once (1µs+0s) by Test::Builder::use_numbers at line 1227 of Test/Builder.pm
# once (900ns+0s) by Test::Builder::reset_outputs at line 1413 of Test/Builder.pm | ||
86 | 147 | 83µs | $out{"set_$attr"} = sub { Carp::croak("'$attr' is read-only") } if $spec->{read_only}; | ||
87 | 147 | 17µs | $out{"set_$attr"} = sub { Carp::carp("set_$attr() is deprecated"); $_[0]->{$attr} = $_[1] } if $spec->{dep_writer}; | ||
88 | |||||
89 | 147 | 138µs | %out; | ||
90 | } @_ | ||||
91 | ), | ||||
92 | ); | ||||
93 | |||||
94 | 2 | 281µs | 2 | 16µs | # spent 12µs (7+4) within Test2::Util::HashBase::BEGIN@94 which was called:
# once (7µs+4µs) by Test2::EventFacet::BEGIN@7 at line 94 # spent 12µs making 1 call to Test2::Util::HashBase::BEGIN@94
# spent 4µs making 1 call to strict::unimport |
95 | 31 | 670µs | *{"$into\::$_"} = $subs{$_} for keys %subs; | ||
96 | } | ||||
97 | |||||
98 | sub attr_list { | ||||
99 | my $class = shift; | ||||
100 | |||||
101 | my $isa = _isa($class); | ||||
102 | |||||
103 | my %seen; | ||||
104 | my @list = grep { !$seen{$_}++ } map { | ||||
105 | my @out; | ||||
106 | |||||
107 | if (0.004 > ($Test2::Util::HashBase::VERSION{$_} || 0)) { | ||||
108 | Carp::carp("$_ uses an inlined version of Test2::Util::HashBase too old to support attr_list()"); | ||||
109 | } | ||||
110 | else { | ||||
111 | my $list = $Test2::Util::HashBase::ATTR_LIST{$_}; | ||||
112 | @out = $list ? @$list : () | ||||
113 | } | ||||
114 | |||||
115 | @out; | ||||
116 | } reverse @$isa; | ||||
117 | |||||
118 | return @list; | ||||
119 | } | ||||
120 | |||||
121 | # spent 226µs (56+170) within Test2::Util::HashBase::_new which was called 10 times, avg 23µs/call:
# once (4µs+86µs) by Test2::Formatter::new_root at line 19 of Test2/Formatter.pm
# once (10µs+20µs) by Test2::Hub::finalize at line 435 of Test2/Hub.pm
# once (9µs+14µs) by Test2::API::Instance::import at line 74 of Test2/API/Instance.pm
# once (5µs+15µs) by Test2::API::test2_set_is_end at line 41 of Test2/API.pm
# once (6µs+14µs) by Test2::API::Stack::new_hub at line 23 of Test2/API/Stack.pm
# once (4µs+12µs) by Test2::API::Context::send_ev2 at line 223 of Test2/API/Context.pm
# once (6µs+6µs) by Test2::API::test2_set_is_end at line 38 of Test2/API.pm
# once (3µs+5µs) by Test2::API::Instance::set_exit at line 541 of Test2/API/Instance.pm
# once (4µs+3µs) by Test2::API::Instance::set_exit at line 537 of Test2/API/Instance.pm
# once (4µs+-4µs) by Test2::Event::V2::init at line 42 of Test2/Event/V2.pm | ||||
122 | 10 | 2µs | my $class = shift; | ||
123 | |||||
124 | 10 | 1µs | my $self; | ||
125 | |||||
126 | 10 | 4µs | if (@_ == 1) { | ||
127 | my $arg = shift; | ||||
128 | my $type = ref($arg); | ||||
129 | |||||
130 | if ($type eq 'HASH') { | ||||
131 | $self = bless({%$arg}, $class) | ||||
132 | } | ||||
133 | else { | ||||
134 | Carp::croak("Not sure what to do with '$type' in $class constructor") | ||||
135 | unless $type eq 'ARRAY'; | ||||
136 | |||||
137 | my %proto; | ||||
138 | my @attributes = attr_list($class); | ||||
139 | while (@$arg) { | ||||
140 | my $val = shift @$arg; | ||||
141 | my $key = shift @attributes or Carp::croak("Too many arguments for $class constructor"); | ||||
142 | $proto{$key} = $val; | ||||
143 | } | ||||
144 | |||||
145 | $self = bless(\%proto, $class); | ||||
146 | } | ||||
147 | } | ||||
148 | else { | ||||
149 | 10 | 7µs | $self = bless({@_}, $class); | ||
150 | } | ||||
151 | |||||
152 | $Test2::Util::HashBase::CAN_CACHE{$class} = $self->can('init') | ||||
153 | 10 | 24µs | 7 | 5µs | unless exists $Test2::Util::HashBase::CAN_CACHE{$class}; # spent 5µs making 7 calls to UNIVERSAL::can, avg 671ns/call |
154 | |||||
155 | 10 | 9µs | 10 | 170µs | $self->init if $Test2::Util::HashBase::CAN_CACHE{$class}; # spent 86µs making 1 call to Test::Builder::Formatter::init
# spent 20µs making 2 calls to Test2::API::Context::init, avg 10µs/call
# spent 19µs making 1 call to Test2::Event::Plan::init
# spent 13µs making 1 call to Test2::API::Instance::init
# spent 13µs making 1 call to Test2::Hub::init
# spent 11µs making 1 call to Test2::Event::V2::init
# spent 9µs making 3 calls to Test2::EventFacet::Trace::init, avg 3µs/call |
156 | |||||
157 | 10 | 13µs | $self; | ||
158 | } | ||||
159 | |||||
160 | 1 | 6µs | 1; | ||
161 | |||||
162 | __END__ |