| Filename | /Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Data/Perl/Collection/Hash/MooseLike.pm |
| Statements | Executed 303531 statements in 572ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 75880 | 1 | 1 | 528ms | 6.61s | Data::Perl::Collection::Hash::MooseLike::__ANON__[:22] |
| 1 | 1 | 1 | 45µs | 159µs | Data::Perl::Collection::Hash::MooseLike::BEGIN@5 |
| 1 | 1 | 1 | 8µs | 38µs | Data::Perl::Collection::Hash::MooseLike::BEGIN@7 |
| 1 | 1 | 1 | 6µs | 33µs | Data::Perl::Collection::Hash::MooseLike::BEGIN@8 |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Data::Perl::Collection::Hash::MooseLike; | ||||
| 2 | 1 | 0s | $Data::Perl::Collection::Hash::MooseLike::VERSION = '0.001009'; | ||
| 3 | # ABSTRACT: Collection::Hash subclass that simulates Moose's native traits. | ||||
| 4 | |||||
| 5 | 3 | 35µs | 3 | 272µs | # spent 159µs (45+114) within Data::Perl::Collection::Hash::MooseLike::BEGIN@5 which was called:
# once (45µs+114µs) by Module::Runtime::require_module at line 5 # spent 159µs making 1 call to Data::Perl::Collection::Hash::MooseLike::BEGIN@5
# spent 86µs making 1 call to strictures::import
# spent 27µs making 1 call to strictures::VERSION |
| 6 | |||||
| 7 | 2 | 32µs | 2 | 68µs | # spent 38µs (8+30) within Data::Perl::Collection::Hash::MooseLike::BEGIN@7 which was called:
# once (8µs+30µs) by Module::Runtime::require_module at line 7 # spent 38µs making 1 call to Data::Perl::Collection::Hash::MooseLike::BEGIN@7
# spent 30µs making 1 call to Exporter::import |
| 8 | 2 | 187µs | 2 | 60µs | # spent 33µs (6+27) within Data::Perl::Collection::Hash::MooseLike::BEGIN@8 which was called:
# once (6µs+27µs) by Module::Runtime::require_module at line 8 # spent 33µs making 1 call to Data::Perl::Collection::Hash::MooseLike::BEGIN@8
# spent 27µs making 1 call to Exporter::import |
| 9 | |||||
| 10 | 1 | 2µs | 1 | 2.13ms | with 'Data::Perl::Role::Collection::Hash'; # spent 2.13ms making 1 call to Role::Tiny::With::with |
| 11 | |||||
| 12 | # spent 6.61s (528ms+6.08) within Data::Perl::Collection::Hash::MooseLike::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Data/Perl/Collection/Hash/MooseLike.pm:22] which was called 75880 times, avg 87µs/call:
# 75880 times (528ms+6.08s) by Data::Perl::Collection::Hash::MooseLike::__ANON__[(eval 280)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Class/Method/Modifiers.pm:89]:1] or Data::Perl::Collection::Hash::MooseLike::__ANON__[(eval 284)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Class/Method/Modifiers.pm:89]:1] at line 1 of (eval 280)[Class/Method/Modifiers.pm:89], avg 87µs/call | ||||
| 13 | 75880 | 19.6ms | my $orig = shift; | ||
| 14 | 75880 | 108ms | 75880 | 6.03s | my @res = $orig->(@_); # spent 6.02s making 75815 calls to Data::Perl::Role::Collection::Hash::get, avg 79µs/call
# spent 7.48ms making 65 calls to Data::Perl::Role::Collection::Hash::set, avg 115µs/call |
| 15 | |||||
| 16 | # support both class instance method invocation style | ||||
| 17 | 75880 | 284ms | 75880 | 54.9ms | @res = blessed($res[0]) # spent 54.9ms making 75880 calls to Scalar::Util::blessed, avg 724ns/call |
| 18 | && ($res[0]->isa('Data::Perl::Collection::Hash') | ||||
| 19 | || $res[0]->isa('Data::Perl::Collection::Array')) ? $res[0]->flatten : @res; | ||||
| 20 | |||||
| 21 | 75880 | 161ms | wantarray ? @res : $res[-1]; | ||
| 22 | 1 | 12µs | 1 | 647µs | }; # spent 647µs making 1 call to Class::Method::Modifiers::around |
| 23 | |||||
| 24 | 1 | 9µs | 1; | ||
| 25 | |||||
| 26 | =pod | ||||
| 27 | |||||
| 28 | =encoding UTF-8 | ||||
| 29 | |||||
| 30 | =head1 NAME | ||||
| 31 | |||||
| 32 | Data::Perl::Collection::Hash::MooseLike - Collection::Hash subclass that simulates Moose's native traits. | ||||
| 33 | |||||
| 34 | =head1 VERSION | ||||
| 35 | |||||
| 36 | version 0.001009 | ||||
| 37 | |||||
| 38 | =head1 SYNOPSIS | ||||
| 39 | |||||
| 40 | use Data::Perl::Collection::Hash::MooseLike; | ||||
| 41 | |||||
| 42 | my $hash = Data::Perl::Collection::Hash::MooseLike->new(a => 1, b => 2); | ||||
| 43 | |||||
| 44 | $hash->values; # (1, 2) | ||||
| 45 | |||||
| 46 | $hash->set('foo', 'bar'); # (a => 1, b => 2, foo => 'bar') | ||||
| 47 | |||||
| 48 | =head1 DESCRIPTION | ||||
| 49 | |||||
| 50 | This class provides a wrapper and methods for interacting with a hash. All | ||||
| 51 | methods are written to emulate/match existing behavior that exists with Moose's | ||||
| 52 | native traits. | ||||
| 53 | |||||
| 54 | =head1 DIFFERENCES IN FUNCTIONALITY | ||||
| 55 | |||||
| 56 | =over 4 | ||||
| 57 | |||||
| 58 | =item B<get($key, $key, ...)> | ||||
| 59 | |||||
| 60 | Returns values from the hash. | ||||
| 61 | |||||
| 62 | In list context it returns a list of values in the hash for the given keys. In | ||||
| 63 | scalar context it returns the value for the last key specified. | ||||
| 64 | |||||
| 65 | =item B<set($key, $value, ...)> | ||||
| 66 | |||||
| 67 | Sets the elements in the hash to the given values. It returns the new values | ||||
| 68 | set for each key, in the same order as the keys passed to the method. | ||||
| 69 | |||||
| 70 | This method requires at least two arguments, and expects an even number of | ||||
| 71 | arguments. | ||||
| 72 | |||||
| 73 | =item B<delete($key, $key, ...)> | ||||
| 74 | |||||
| 75 | Removes the elements with the given keys. | ||||
| 76 | |||||
| 77 | In list context it returns a list of values in the hash for the deleted keys. | ||||
| 78 | In scalar context it returns the value for the last key specified. | ||||
| 79 | |||||
| 80 | =back | ||||
| 81 | |||||
| 82 | =head1 SEE ALSO | ||||
| 83 | |||||
| 84 | =over 4 | ||||
| 85 | |||||
| 86 | =item * L<Data::Perl> | ||||
| 87 | |||||
| 88 | =item * L<Data::Perl::Role::Collection::Hash> | ||||
| 89 | |||||
| 90 | =back | ||||
| 91 | |||||
| 92 | =head1 AUTHOR | ||||
| 93 | |||||
| 94 | Toby Inkster <tobyink@cpan.org> | ||||
| 95 | |||||
| 96 | =head1 COPYRIGHT AND LICENSE | ||||
| 97 | |||||
| 98 | This software is copyright (c) 2020 by Matthew Phillips <mattp@cpan.org>. | ||||
| 99 | |||||
| 100 | This is free software; you can redistribute it and/or modify it under | ||||
| 101 | the same terms as the Perl 5 programming language system itself. | ||||
| 102 | |||||
| 103 | =cut | ||||
| 104 | |||||
| 105 | __END__ |