← 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
StatementsExecuted 43 statements in 334µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
33114µs17µsTest2::Util::ExternalMeta::::metaTest2::Util::ExternalMeta::meta
11110µs11µsTest2::Util::ExternalMeta::::BEGIN@2Test2::Util::ExternalMeta::BEGIN@2
1117µs7µsTest2::Util::ExternalMeta::::BEGIN@13Test2::Util::ExternalMeta::BEGIN@13
3114µs4µsTest2::Util::ExternalMeta::::validate_keyTest2::Util::ExternalMeta::validate_key
1114µs19µsTest2::Util::ExternalMeta::::BEGIN@8Test2::Util::ExternalMeta::BEGIN@8
1113µs20µsTest2::Util::ExternalMeta::::BEGIN@3Test2::Util::ExternalMeta::BEGIN@3
0000s0sTest2::Util::ExternalMeta::::delete_metaTest2::Util::ExternalMeta::delete_meta
0000s0sTest2::Util::ExternalMeta::::get_metaTest2::Util::ExternalMeta::get_meta
0000s0sTest2::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
1package Test2::Util::ExternalMeta;
2218µs213µ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
3227µs236µ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
51400nsour $VERSION = '1.302198';
6
7
8246µs234µ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
10sub META_KEY() { '_meta' }
11
121800nsour @EXPORT = qw/meta set_meta get_meta delete_meta/;
132221µs17µ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
15sub 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
25sub 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
35sub 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 {
463500ns my $self = shift;
4731µs my ($key, $default) = @_;
48
4933µs34µs validate_key($key);
# spent 4µs making 3 calls to Test2::Util::ExternalMeta::validate_key, avg 1µs/call
50
513900ns my $meta = $self->{+META_KEY};
523600ns return undef unless $meta || defined($default);
53
543600ns unless($meta) {
551200ns $meta = {};
561300ns $self->{+META_KEY} = $meta;
57 }
58
59 $meta->{$key} = $default
6032µs if defined($default) && !defined($meta->{$key});
61
6235µ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 {
663500ns my $key = shift;
67
6835µ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
7412µs1;
75
76__END__