Profile of Test2/Util/ExternalMeta.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/Util/ExternalMeta.pm
Statements | Executed 43 statements in 334µs

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
3 | 3 | 1 | 14µs | 17µs | Test2::Util::ExternalMeta::::metaTest2::Util::ExternalMeta::meta
1 | 1 | 1 | 10µs | 11µs | Test2::Util::ExternalMeta::::BEGIN@2Test2::Util::ExternalMeta::BEGIN@2
1 | 1 | 1 | 7µs | 7µs | Test2::Util::ExternalMeta::::BEGIN@13Test2::Util::ExternalMeta::BEGIN@13
3 | 1 | 1 | 4µs | 4µs | Test2::Util::ExternalMeta::::validate_keyTest2::Util::ExternalMeta::validate_key
1 | 1 | 1 | 4µs | 19µs | Test2::Util::ExternalMeta::::BEGIN@8Test2::Util::ExternalMeta::BEGIN@8
1 | 1 | 1 | 3µs | 20µs | Test2::Util::ExternalMeta::::BEGIN@3Test2::Util::ExternalMeta::BEGIN@3
0 | 0 | 0 | 0s | 0s | Test2::Util::ExternalMeta::::delete_metaTest2::Util::ExternalMeta::delete_meta
0 | 0 | 0 | 0s | 0s | Test2::Util::ExternalMeta::::get_metaTest2::Util::ExternalMeta::get_meta
0 | 0 | 0 | 0s | 0s | Test2::Util::ExternalMeta::::set_metaTest2::Util::ExternalMeta::set_meta

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::Util::ExternalMeta;
2 | 2 | 18µs | 2 | 13µs | # spent 11µs (10+2) within Test2::Util::ExternalMeta::BEGIN@2 which was called: # once (10µs+2µs) by Test2::Hub::BEGIN@14 at line 2 use strict; # spent 11µs making 1 call to Test2::Util::ExternalMeta::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::Util::ExternalMeta::BEGIN@3 which was called: # once (3µs+16µs) by Test2::Hub::BEGIN@14 at line 3 use warnings; # spent 20µs making 1 call to Test2::Util::ExternalMeta::BEGIN@3 # spent 16µs making 1 call to warnings::import
4 |  |  |  |  |
5 | 1 | 400ns |  |  | our $VERSION = '1.302198';
6 |  |  |  |  |
7 |  |  |  |  |
8 | 2 | 46µs | 2 | 34µs | # spent 19µs (4+15) within Test2::Util::ExternalMeta::BEGIN@8 which was called: # once (4µs+15µs) by Test2::Hub::BEGIN@14 at line 8 use Carp qw/croak/; # spent 19µs making 1 call to Test2::Util::ExternalMeta::BEGIN@8 # spent 15µs making 1 call to Exporter::import
9 |  |  |  |  |
10 |  |  |  |  | sub META_KEY() { '_meta' }
11 |  |  |  |  |
12 | 1 | 800ns |  |  | our @EXPORT = qw/meta set_meta get_meta delete_meta/;
13 | 2 | 221µs | 1 | 7µs | # spent 7µs within Test2::Util::ExternalMeta::BEGIN@13 which was called: # once (7µs+0s) by Test2::Hub::BEGIN@14 at line 13 BEGIN { require Exporter; our @ISA = qw(Exporter) } # spent 7µs making 1 call to Test2::Util::ExternalMeta::BEGIN@13
14 |  |  |  |  |
15 |  |  |  |  | sub set_meta {
16 |  |  |  |  | my $self = shift;
17 |  |  |  |  | my ($key, $value) = @_;
18 |  |  |  |  |
19 |  |  |  |  | validate_key($key);
20 |  |  |  |  |
21 |  |  |  |  | $self->{+META_KEY} ||= {};
22 |  |  |  |  | $self->{+META_KEY}->{$key} = $value;
23 |  |  |  |  | }
24 |  |  |  |  |
25 |  |  |  |  | sub get_meta {
26 |  |  |  |  | my $self = shift;
27 |  |  |  |  | my ($key) = @_;
28 |  |  |  |  |
29 |  |  |  |  | validate_key($key);
30 |  |  |  |  |
31 |  |  |  |  | my $meta = $self->{+META_KEY} or return undef;
32 |  |  |  |  | return $meta->{$key};
33 |  |  |  |  | }
34 |  |  |  |  |
35 |  |  |  |  | sub delete_meta {
36 |  |  |  |  | my $self = shift;
37 |  |  |  |  | my ($key) = @_;
38 |  |  |  |  |
39 |  |  |  |  | validate_key($key);
40 |  |  |  |  |
41 |  |  |  |  | my $meta = $self->{+META_KEY} or return undef;
42 |  |  |  |  | delete $meta->{$key};
43 |  |  |  |  | }
44 |  |  |  |  |
45 |  |  |  |  | # spent 17µs (14+4) within Test2::Util::ExternalMeta::meta which was called 3 times, avg 6µs/call: # once (6µs+2µs) by Test::Builder::done_testing at line 586 of Test/Builder.pm # once (5µs+1µs) by Test::Builder::reset at line 455 of Test/Builder.pm # once (3µs+900ns) by Test::Builder::_ending at line 1657 of Test/Builder.pm sub meta {
46 | 3 | 500ns |  |  | my $self = shift;
47 | 3 | 1µs |  |  | my ($key, $default) = @_;
48 |  |  |  |  |
49 | 3 | 3µs | 3 | 4µs | validate_key($key); # spent 4µs making 3 calls to Test2::Util::ExternalMeta::validate_key, avg 1µs/call
50 |  |  |  |  |
51 | 3 | 900ns |  |  | my $meta = $self->{+META_KEY};
52 | 3 | 600ns |  |  | return undef unless $meta || defined($default);
53 |  |  |  |  |
54 | 3 | 600ns |  |  | unless($meta) {
55 | 1 | 200ns |  |  | $meta = {};
56 | 1 | 300ns |  |  | $self->{+META_KEY} = $meta;
57 |  |  |  |  | }
58 |  |  |  |  |
59 |  |  |  |  | $meta->{$key} = $default
60 | 3 | 2µs |  |  | if defined($default) && !defined($meta->{$key});
61 |  |  |  |  |
62 | 3 | 5µs |  |  | return $meta->{$key};
63 |  |  |  |  | }
64 |  |  |  |  |
65 |  |  |  |  | # spent 4µs within Test2::Util::ExternalMeta::validate_key which was called 3 times, avg 1µs/call: # 3 times (4µs+0s) by Test2::Util::ExternalMeta::meta at line 49, avg 1µs/call sub validate_key {
66 | 3 | 500ns |  |  | my $key = shift;
67 |  |  |  |  |
68 | 3 | 5µs |  |  | return if $key && !ref($key);
69 |  |  |  |  |
70 |  |  |  |  | my $render_key = defined($key) ? "'$key'" : 'undef';
71 |  |  |  |  | croak "Invalid META key: $render_key, keys must be true, and may not be references";
72 |  |  |  |  | }
73 |  |  |  |  |
74 | 1 | 2µs |  |  | 1;
75 |  |  |  |  |
76 |  |  |  |  | __END__