| Filename | /home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/KiokuDB/LiveObjects/Scope.pm |
| Statements | Executed 11 statements in 1.11ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 70µs | 21.6ms | KiokuDB::LiveObjects::Scope::BEGIN@4 |
| 1 | 1 | 1 | 46µs | 1.55ms | KiokuDB::LiveObjects::Scope::BEGIN@6 |
| 0 | 0 | 0 | 0s | 0s | KiokuDB::LiveObjects::Scope::DEMOLISH |
| 0 | 0 | 0 | 0s | 0s | KiokuDB::LiveObjects::Scope::__ANON__[:11] |
| 0 | 0 | 0 | 0s | 0s | KiokuDB::LiveObjects::Scope::detach |
| 0 | 0 | 0 | 0s | 0s | KiokuDB::LiveObjects::Scope::remove |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | #!/usr/bin/perl | ||||
| 2 | |||||
| 3 | package KiokuDB::LiveObjects::Scope; | ||||
| 4 | 3 | 171µs | 2 | 43.2ms | # spent 21.6ms (70µs+21.6) within KiokuDB::LiveObjects::Scope::BEGIN@4 which was called:
# once (70µs+21.6ms) by KiokuDB::LiveObjects::BEGIN@13 at line 4 # spent 21.6ms making 1 call to KiokuDB::LiveObjects::Scope::BEGIN@4
# spent 21.6ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:456] |
| 5 | |||||
| 6 | 3 | 757µs | 2 | 3.06ms | # spent 1.55ms (46µs+1.51) within KiokuDB::LiveObjects::Scope::BEGIN@6 which was called:
# once (46µs+1.51ms) by KiokuDB::LiveObjects::BEGIN@13 at line 6 # spent 1.55ms making 1 call to KiokuDB::LiveObjects::Scope::BEGIN@6
# spent 1.51ms making 1 call to namespace::clean::import |
| 7 | |||||
| 8 | has objects => ( | ||||
| 9 | traits => [qw(Array)], | ||||
| 10 | isa => "ArrayRef", | ||||
| 11 | default => sub { [] }, | ||||
| 12 | 1 | 31µs | 1 | 567ms | clearer => "_clear_objects", # spent 567ms making 1 call to Moose::has |
| 13 | handles => { | ||||
| 14 | push => "push", | ||||
| 15 | objects => "elements", | ||||
| 16 | clear => "clear", | ||||
| 17 | }, | ||||
| 18 | ); | ||||
| 19 | |||||
| 20 | 1 | 12µs | 1 | 7.93ms | has parent => ( # spent 7.93ms making 1 call to Moose::has |
| 21 | isa => __PACKAGE__, | ||||
| 22 | is => "ro", | ||||
| 23 | ); | ||||
| 24 | |||||
| 25 | 1 | 12µs | 1 | 11.7ms | has live_objects => ( # spent 11.7ms making 1 call to Moose::has |
| 26 | isa => "KiokuDB::LiveObjects", | ||||
| 27 | is => "ro", | ||||
| 28 | clearer => "_clear_live_objects", | ||||
| 29 | ); | ||||
| 30 | |||||
| 31 | sub DEMOLISH { | ||||
| 32 | my $self = shift; | ||||
| 33 | |||||
| 34 | # consider possibilities of optimizing live object set removal at this | ||||
| 35 | # point | ||||
| 36 | |||||
| 37 | # problems can arise from an object outliving the scope it was loaded in: | ||||
| 38 | # { my $outer = lookup(...); { my $inner = lookup(...); $outer->foo($inner) } } | ||||
| 39 | |||||
| 40 | $self->remove; | ||||
| 41 | } | ||||
| 42 | |||||
| 43 | sub detach { | ||||
| 44 | my $self = shift; | ||||
| 45 | |||||
| 46 | if ( my $l = $self->live_objects ) { | ||||
| 47 | $l->detach_scope($self); | ||||
| 48 | } | ||||
| 49 | } | ||||
| 50 | |||||
| 51 | sub remove { | ||||
| 52 | my $self = shift; | ||||
| 53 | |||||
| 54 | if ( my $l = $self->live_objects ) { # can be false under global destruction | ||||
| 55 | $l->remove_scope($self); | ||||
| 56 | $self->_clear_live_objects; | ||||
| 57 | } | ||||
| 58 | } | ||||
| 59 | |||||
| 60 | 1 | 25µs | 2 | 16.8ms | __PACKAGE__->meta->make_immutable; # spent 16.7ms making 1 call to Class::MOP::Class::make_immutable
# spent 102µs making 1 call to KiokuDB::LiveObjects::Scope::meta |
| 61 | |||||
| 62 | 1 | 62µs | __PACKAGE__ | ||
| 63 | |||||
| 64 | 1 | 37µs | 1 | 4.34ms | __END__ # spent 4.34ms making 1 call to B::Hooks::EndOfScope::__ANON__[B/Hooks/EndOfScope.pm:26] |