← Index
NYTProf Performance Profile   « line view »
For t/bug-md-11.t
  Run on Fri Mar 8 13:27:24 2024
Reported on Fri Mar 8 13:30:23 2024

Filename/home/micha/.plenv/versions/5.38.2/lib/perl5/site_perl/5.38.2/Test2/Util/HashBase.pm
StatementsExecuted 2336 statements in 3.26ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
3131312.14ms2.22msTest2::Util::HashBase::::importTest2::Util::HashBase::import
111208µs355µsTest2::Util::HashBase::::BEGIN@33Test2::Util::HashBase::BEGIN@33
1010756µs226µsTest2::Util::HashBase::::_newTest2::Util::HashBase::_new (recurses: max depth 1, inclusive time 4µs)
4942538µs38µsTest2::Util::HashBase::::__ANON__[:84]Test2::Util::HashBase::__ANON__[:84]
1119µs11µsTest2::Util::HashBase::::BEGIN@2Test2::Util::HashBase::BEGIN@2
1117µs12µsTest2::Util::HashBase::::BEGIN@94Test2::Util::HashBase::BEGIN@94
1115µs9µsTest2::Util::HashBase::::BEGIN@37Test2::Util::HashBase::BEGIN@37
1114µs15µsTest2::Util::HashBase::::BEGIN@18Test2::Util::HashBase::BEGIN@18
1114µs14µsTest2::Util::HashBase::::BEGIN@29Test2::Util::HashBase::BEGIN@29
1113µs18µsTest2::Util::HashBase::::BEGIN@3Test2::Util::HashBase::BEGIN@3
2212µs2µsTest2::Util::HashBase::::__ANON__[:85]Test2::Util::HashBase::__ANON__[:85]
0000s0sTest2::Util::HashBase::::__ANON__[:44]Test2::Util::HashBase::__ANON__[:44]
0000s0sTest2::Util::HashBase::::__ANON__[:81]Test2::Util::HashBase::__ANON__[:81]
0000s0sTest2::Util::HashBase::::__ANON__[:86]Test2::Util::HashBase::__ANON__[:86]
0000s0sTest2::Util::HashBase::::__ANON__[:87]Test2::Util::HashBase::__ANON__[:87]
0000s0sTest2::Util::HashBase::::attr_listTest2::Util::HashBase::attr_list
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Test2::Util::HashBase;
2217µs212µ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
use strict;
# spent 11µs making 1 call to Test2::Util::HashBase::BEGIN@2 # spent 2µs making 1 call to strict::import
3230µs233µ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
use warnings;
# spent 18µs making 1 call to Test2::Util::HashBase::BEGIN@3 # spent 15µs making 1 call to warnings::import
4
51400nsour $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{
18352µs225µ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
no warnings 'once';
# spent 15µs making 1 call to Test2::Util::HashBase::BEGIN@18 # spent 11µs making 1 call to warnings::unimport
191100ns $Test2::Util::HashBase::HB_VERSION = '0.009';
2011µs *Test2::Util::HashBase::ATTR_SUBS = \%Object::HashBase::ATTR_SUBS;
211100ns *Test2::Util::HashBase::ATTR_LIST = \%Object::HashBase::ATTR_LIST;
221200ns *Test2::Util::HashBase::VERSION = \%Object::HashBase::VERSION;
231300ns *Test2::Util::HashBase::CAN_CACHE = \%Object::HashBase::CAN_CACHE;
24}
25
26
271400nsrequire Carp;
28{
29342µs224µ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
no warnings 'once';
# spent 14µs making 1 call to Test2::Util::HashBase::BEGIN@29 # spent 10µs making 1 call to warnings::unimport
301500ns $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
BEGIN {
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 {
37269µs213µ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
no strict 'refs';
# 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 }
451336µs1355µs}
# spent 355µs making 1 call to Test2::Util::HashBase::BEGIN@33
46
4714µsmy %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
sub import {
56319µs my $class = shift;
573112µs my $into = caller;
58
59 # Make sure we list the OLDEST version used to create this class.
60318µs my $ver = $Test2::Util::HashBase::HB_VERSION || $Test2::Util::HashBase::VERSION;
613128µs $Test2::Util::HashBase::VERSION{$into} = $ver if !$Test2::Util::HashBase::VERSION{$into} || $Test2::Util::HashBase::VERSION{$into} > $ver;
62
633193µs3134µs my $isa = _isa($into);
# spent 34µs making 31 calls to mro::get_linear_isa, avg 1µs/call
643115µs my $attr_list = $Test2::Util::HashBase::ATTR_LIST{$into} ||= [];
653111µ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 {
72178347µs3144µs my $p = substr($_, 0, 1);
# spent 44µs making 31 calls to UNIVERSAL::can, avg 1µs/call
7314715µs my $x = $_;
74
7514755µs my $spec = $SPEC{$p} || {reader => 1, writer => 1};
76
7714729µs substr($x, 0, 1) = '' if $spec->{strip};
7814742µs push @$attr_list => $x;
7914751µs my ($sub, $attr) = (uc $x, $x);
80
81147289µs $attr_subs->{$sub} = sub() { $attr };
8214750µs my %out = ($sub => $attr_subs->{$sub});
83
84196203µ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
$out{$attr} = sub { $_[0]->{$attr} } if $spec->{reader};
85149192µ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
$out{"set_$attr"} = sub { $_[0]->{$attr} = $_[1] } if $spec->{writer};
8614783µs $out{"set_$attr"} = sub { Carp::croak("'$attr' is read-only") } if $spec->{read_only};
8714717µs $out{"set_$attr"} = sub { Carp::carp("set_$attr() is deprecated"); $_[0]->{$attr} = $_[1] } if $spec->{dep_writer};
88
89147138µs %out;
90 } @_
91 ),
92 );
93
942281µs216µ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
no strict 'refs';
# spent 12µs making 1 call to Test2::Util::HashBase::BEGIN@94 # spent 4µs making 1 call to strict::unimport
9531670µs *{"$into\::$_"} = $subs{$_} for keys %subs;
96}
97
98sub 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
sub _new {
122102µs my $class = shift;
123
124101µs my $self;
125
126104µ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 {
149107µs $self = bless({@_}, $class);
150 }
151
152 $Test2::Util::HashBase::CAN_CACHE{$class} = $self->can('init')
1531024µs75µs unless exists $Test2::Util::HashBase::CAN_CACHE{$class};
# spent 5µs making 7 calls to UNIVERSAL::can, avg 671ns/call
154
155109µs10170µ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
1571013µs $self;
158}
159
16016µs1;
161
162__END__