| Filename | /Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Data/Perl/Collection/Hash/MooseLike.pm |
| Statements | Executed 294863 statements in 614ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 73713 | 1 | 1 | 545ms | 7.64s | Data::Perl::Collection::Hash::MooseLike::__ANON__[:22] |
| 1 | 1 | 1 | 50µs | 173µs | Data::Perl::Collection::Hash::MooseLike::BEGIN@5 |
| 1 | 1 | 1 | 10µs | 43µs | Data::Perl::Collection::Hash::MooseLike::BEGIN@7 |
| 1 | 1 | 1 | 6µs | 42µ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 | 46µs | 3 | 296µs | # spent 173µs (50+123) within Data::Perl::Collection::Hash::MooseLike::BEGIN@5 which was called:
# once (50µs+123µs) by Module::Runtime::require_module at line 5 # spent 173µs making 1 call to Data::Perl::Collection::Hash::MooseLike::BEGIN@5
# spent 94µs making 1 call to strictures::import
# spent 29µs making 1 call to strictures::VERSION |
| 6 | |||||
| 7 | 2 | 36µs | 2 | 76µs | # spent 43µs (10+33) within Data::Perl::Collection::Hash::MooseLike::BEGIN@7 which was called:
# once (10µs+33µs) by Module::Runtime::require_module at line 7 # spent 43µs making 1 call to Data::Perl::Collection::Hash::MooseLike::BEGIN@7
# spent 33µs making 1 call to Exporter::import |
| 8 | 2 | 224µs | 2 | 78µs | # spent 42µs (6+36) within Data::Perl::Collection::Hash::MooseLike::BEGIN@8 which was called:
# once (6µs+36µs) by Module::Runtime::require_module at line 8 # spent 42µs making 1 call to Data::Perl::Collection::Hash::MooseLike::BEGIN@8
# spent 36µs making 1 call to Exporter::import |
| 9 | |||||
| 10 | 1 | 1µs | 1 | 1.83ms | with 'Data::Perl::Role::Collection::Hash'; # spent 1.83ms making 1 call to Role::Tiny::With::with |
| 11 | |||||
| 12 | # spent 7.64s (545ms+7.10) 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 73713 times, avg 104µs/call:
# 73713 times (545ms+7.10s) by Data::Perl::Collection::Hash::MooseLike::__ANON__[(eval 284)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Class/Method/Modifiers.pm:89]:1] or Data::Perl::Collection::Hash::MooseLike::__ANON__[(eval 288)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Class/Method/Modifiers.pm:89]:1] at line 1 of (eval 284)[Class/Method/Modifiers.pm:89], avg 104µs/call | ||||
| 13 | 73713 | 22.9ms | my $orig = shift; | ||
| 14 | 73713 | 117ms | 73713 | 7.03s | my @res = $orig->(@_); # spent 7.02s making 73648 calls to Data::Perl::Role::Collection::Hash::get, avg 95µs/call
# spent 9.14ms making 65 calls to Data::Perl::Role::Collection::Hash::set, avg 141µs/call |
| 15 | |||||
| 16 | # support both class instance method invocation style | ||||
| 17 | 73713 | 270ms | 73713 | 66.2ms | @res = blessed($res[0]) # spent 66.2ms making 73713 calls to Scalar::Util::blessed, avg 897ns/call |
| 18 | && ($res[0]->isa('Data::Perl::Collection::Hash') | ||||
| 19 | || $res[0]->isa('Data::Perl::Collection::Array')) ? $res[0]->flatten : @res; | ||||
| 20 | |||||
| 21 | 73713 | 204ms | wantarray ? @res : $res[-1]; | ||
| 22 | 1 | 3µs | 1 | 742µs | }; # spent 742µs making 1 call to Class::Method::Modifiers::around |
| 23 | |||||
| 24 | 1 | 8µ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__ |