Profile of Test2/API/Stack.pm

← 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
Statements | Executed 38 statements in 474µs

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
1 | 1 | 1 | 1.89ms | 2.81ms | Test2::API::Stack::::BEGIN@8Test2::API::Stack::BEGIN@8
1 | 1 | 1 | 22µs | 41µs | Test2::API::Stack::::BEGIN@3Test2::API::Stack::BEGIN@3
1 | 1 | 1 | 14µs | 155µs | Test2::API::Stack::::new_hubTest2::API::Stack::new_hub
1 | 1 | 1 | 11µs | 13µs | Test2::API::Stack::::BEGIN@2Test2::API::Stack::BEGIN@2
1 | 1 | 1 | 6µs | 25µs | Test2::API::Stack::::BEGIN@10Test2::API::Stack::BEGIN@10
1 | 1 | 1 | 6µs | 20µs | Test2::API::Stack::::BEGIN@81Test2::API::Stack::BEGIN@81
2 | 2 | 2 | 3µs | 158µs | Test2::API::Stack::::topTest2::API::Stack::top
1 | 1 | 1 | 2µs | 2µs | Test2::API::Stack::::rootTest2::API::Stack::root
1 | 1 | 1 | 2µs | 2µs | Test2::API::Stack::::allTest2::API::Stack::all
1 | 1 | 1 | 1µs | 1µs | Test2::API::Stack::::newTest2::API::Stack::new
0 | 0 | 0 | 0s | 0s | Test2::API::Stack::::__ANON__[:100]Test2::API::Stack::__ANON__[:100]
0 | 0 | 0 | 0s | 0s | Test2::API::Stack::::__ANON__[:88]Test2::API::Stack::__ANON__[:88]
0 | 0 | 0 | 0s | 0s | Test2::API::Stack::::clearTest2::API::Stack::clear
0 | 0 | 0 | 0s | 0s | Test2::API::Stack::::cullTest2::API::Stack::cull
0 | 0 | 0 | 0s | 0s | Test2::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
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package Test2::API::Stack;
2 | 2 | 27µs | 2 | 14µ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
3 | 2 | 39µs | 2 | 61µ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 |  |  |  |  |
5 | 1 | 400ns |  |  | our $VERSION = '1.302198';
6 |  |  |  |  |
7 |  |  |  |  |
8 | 2 | 88µs | 1 | 2.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 |  |  |  |  |
10 | 2 | 200µs | 2 | 44µ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 {
13 | 1 | 200ns |  |  | my $class = shift;
14 | 1 | 2µ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 {
18 | 1 | 100ns |  |  | my $self = shift;
19 | 1 | 200ns |  |  | my %params = @_;
20 |  |  |  |  |
21 | 1 | 400ns |  |  | my $class = delete $params{class} || 'Test2::Hub';
22 |  |  |  |  |
23 | 1 | 1µs | 1 | 20µs | my $hub = $class->new(%params); # spent 20µs making 1 call to Test2::Util::HashBase::_new
24 |  |  |  |  |
25 | 1 | 500ns |  |  | if (@$self) {
26 |  |  |  |  | $hub->inherit($self->[-1], %params);
27 |  |  |  |  | }
28 |  |  |  |  | else {
29 | 1 | 500ns |  |  | require Test2::API;
30 |  |  |  |  | $hub->format(Test2::API::test2_formatter()->new_root)
31 | 1 | 5µs | 4 | 116µ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 |  |  |  |  |
33 | 1 | 700ns | 1 | 4µs | my $ipc = Test2::API::test2_ipc(); # spent 4µs making 1 call to Test2::API::test2_ipc
34 | 1 | 400ns |  |  | if ($ipc && !$hub->ipc && !exists($params{ipc})) {
35 |  |  |  |  | $hub->set_ipc($ipc);
36 |  |  |  |  | $ipc->add_hub($hub->hid);
37 |  |  |  |  | }
38 |  |  |  |  | }
39 |  |  |  |  |
40 | 1 | 400ns |  |  | push @$self => $hub;
41 |  |  |  |  |
42 | 1 | 2µ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 {
46 | 2 | 300ns |  |  | my $self = shift;
47 | 2 | 2µs | 1 | 155µs | return $self->new_hub unless @$self; # spent 155µs making 1 call to Test2::API::Stack::new_hub
48 | 1 | 1µs |  |  | return $self->[-1];
49 |  |  |  |  | }
50 |  |  |  |  |
51 |  |  |  |  | sub peek {
52 |  |  |  |  | my $self = shift;
53 |  |  |  |  | return @$self ? $self->[-1] : undef;
54 |  |  |  |  | }
55 |  |  |  |  |
56 |  |  |  |  | sub 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 {
62 | 1 | 300ns |  |  | my $self = shift;
63 | 1 | 2µ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 {
67 | 1 | 300ns |  |  | my $self = shift;
68 | 1 | 300ns |  |  | return unless @$self;
69 | 1 | 2µs |  |  | return $self->[0];
70 |  |  |  |  | }
71 |  |  |  |  |
72 |  |  |  |  | sub 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 |  |  |  |  | {
81 | 3 | 92µs | 2 | 34µ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;
88 | 1 | 2µ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;
100 | 1 | 700ns |  |  | };
101 |  |  |  |  | }
102 |  |  |  |  |
103 | 1 | 3µs |  |  | 1;
104 |  |  |  |  |
105 |  |  |  |  | __END__