← 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/API/Stack.pm
StatementsExecuted 38 statements in 474µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.89ms2.81msTest2::API::Stack::::BEGIN@8Test2::API::Stack::BEGIN@8
11122µs41µsTest2::API::Stack::::BEGIN@3Test2::API::Stack::BEGIN@3
11114µs155µsTest2::API::Stack::::new_hubTest2::API::Stack::new_hub
11111µs13µsTest2::API::Stack::::BEGIN@2Test2::API::Stack::BEGIN@2
1116µs25µsTest2::API::Stack::::BEGIN@10Test2::API::Stack::BEGIN@10
1116µs20µsTest2::API::Stack::::BEGIN@81Test2::API::Stack::BEGIN@81
2223µs158µsTest2::API::Stack::::topTest2::API::Stack::top
1112µs2µsTest2::API::Stack::::rootTest2::API::Stack::root
1112µs2µsTest2::API::Stack::::allTest2::API::Stack::all
1111µs1µsTest2::API::Stack::::newTest2::API::Stack::new
0000s0sTest2::API::Stack::::__ANON__[:100]Test2::API::Stack::__ANON__[:100]
0000s0sTest2::API::Stack::::__ANON__[:88]Test2::API::Stack::__ANON__[:88]
0000s0sTest2::API::Stack::::clearTest2::API::Stack::clear
0000s0sTest2::API::Stack::::cullTest2::API::Stack::cull
0000s0sTest2::API::Stack::::peekTest2::API::Stack::peek
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Test2::API::Stack;
2227µs214µs
# spent 13µs (11+2) within Test2::API::Stack::BEGIN@2 which was called: # once (11µs+2µs) by Test2::API::Instance::BEGIN@14 at line 2
use strict;
# spent 13µs making 1 call to Test2::API::Stack::BEGIN@2 # spent 2µs making 1 call to strict::import
3239µs261µs
# spent 41µs (22+19) within Test2::API::Stack::BEGIN@3 which was called: # once (22µs+19µs) by Test2::API::Instance::BEGIN@14 at line 3
use warnings;
# spent 41µs making 1 call to Test2::API::Stack::BEGIN@3 # spent 19µs making 1 call to warnings::import
4
51400nsour $VERSION = '1.302198';
6
7
8288µs12.81ms
# spent 2.81ms (1.89+927µs) within Test2::API::Stack::BEGIN@8 which was called: # once (1.89ms+927µs) by Test2::API::Instance::BEGIN@14 at line 8
use Test2::Hub();
# spent 2.81ms making 1 call to Test2::API::Stack::BEGIN@8
9
102200µs244µs
# spent 25µs (6+19) within Test2::API::Stack::BEGIN@10 which was called: # once (6µs+19µs) by Test2::API::Instance::BEGIN@14 at line 10
use Carp qw/confess/;
# spent 25µs making 1 call to Test2::API::Stack::BEGIN@10 # spent 19µs making 1 call to Exporter::import
11
12
# spent 1µs within Test2::API::Stack::new which was called: # once (1µs+0s) by Test2::API::Instance::reset at line 156 of Test2/API/Instance.pm
sub new {
131200ns my $class = shift;
1412µs return bless [], $class;
15}
16
17
# spent 155µs (14+140) within Test2::API::Stack::new_hub which was called: # once (14µs+140µs) by Test2::API::Stack::top at line 47
sub new_hub {
181100ns my $self = shift;
191200ns my %params = @_;
20
211400ns my $class = delete $params{class} || 'Test2::Hub';
22
2311µs120µs my $hub = $class->new(%params);
# spent 20µs making 1 call to Test2::Util::HashBase::_new
24
251500ns if (@$self) {
26 $hub->inherit($self->[-1], %params);
27 }
28 else {
291500ns require Test2::API;
30 $hub->format(Test2::API::test2_formatter()->new_root)
3115µs4116µs unless $hub->format || exists($params{formatter});
# spent 93µs making 1 call to Test2::Formatter::new_root # spent 21µs making 1 call to Test2::API::test2_formatter # spent 3µs making 2 calls to Test2::Hub::format, avg 1µs/call
32
331700ns14µs my $ipc = Test2::API::test2_ipc();
# spent 4µs making 1 call to Test2::API::test2_ipc
341400ns if ($ipc && !$hub->ipc && !exists($params{ipc})) {
35 $hub->set_ipc($ipc);
36 $ipc->add_hub($hub->hid);
37 }
38 }
39
401400ns push @$self => $hub;
41
4212µs $hub;
43}
44
45
# spent 158µs (3+155) within Test2::API::Stack::top which was called 2 times, avg 79µs/call: # once (2µs+155µs) by Test2::API::context at line 386 of Test2/API.pm # once (900ns+0s) by Test::Builder::_add_ts_hooks at line 45 of Test/Builder.pm
sub top {
462300ns my $self = shift;
4722µs1155µs return $self->new_hub unless @$self;
# spent 155µs making 1 call to Test2::API::Stack::new_hub
4811µs return $self->[-1];
49}
50
51sub peek {
52 my $self = shift;
53 return @$self ? $self->[-1] : undef;
54}
55
56sub cull {
57 my $self = shift;
58 $_->cull for reverse @$self;
59}
60
61
# spent 2µs within Test2::API::Stack::all which was called: # once (2µs+0s) by Test2::API::Instance::set_exit at line 520 of Test2/API/Instance.pm
sub all {
621300ns my $self = shift;
6312µs return @$self;
64}
65
66
# spent 2µs within Test2::API::Stack::root which was called: # once (2µs+0s) by Test2::API::test2_set_is_end at line 31 of Test2/API.pm
sub root {
671300ns my $self = shift;
681300ns return unless @$self;
6912µs return $self->[0];
70}
71
72sub clear {
73 my $self = shift;
74 @$self = ();
75}
76
77# Do these last without keywords in order to prevent them from getting used
78# when we want the real push/pop.
79
80{
81392µs234µs
# spent 20µs (6+14) within Test2::API::Stack::BEGIN@81 which was called: # once (6µs+14µs) by Test2::API::Instance::BEGIN@14 at line 81
no warnings 'once';
# spent 20µs making 1 call to Test2::API::Stack::BEGIN@81 # spent 14µs making 1 call to warnings::unimport
82
83 *push = sub {
84 my $self = shift;
85 my ($hub) = @_;
86 $hub->inherit($self->[-1]) if @$self;
87 push @$self => $hub;
8812µs };
89
90 *pop = sub {
91 my $self = shift;
92 my ($hub) = @_;
93 confess "No hubs on the stack"
94 unless @$self;
95 confess "You cannot pop the root hub"
96 if 1 == @$self;
97 confess "Hub stack mismatch, attempted to pop incorrect hub"
98 unless $self->[-1] == $hub;
99 pop @$self;
1001700ns };
101}
102
10313µs1;
104
105__END__