← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 21:42:38 2010
Reported on Wed Nov 17 22:08:25 2010

Filename/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/KiokuDB/Collapser/Buffer.pm
StatementsExecuted 23 statements in 5.68ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11113.6ms17.4msKiokuDB::Collapser::Buffer::::BEGIN@5KiokuDB::Collapser::Buffer::BEGIN@5
111124µs338µsKiokuDB::Collapser::Buffer::::BEGIN@4KiokuDB::Collapser::Buffer::BEGIN@4
11176µs21.4msKiokuDB::Collapser::Buffer::::BEGIN@2KiokuDB::Collapser::Buffer::BEGIN@2
11144µs1.61msKiokuDB::Collapser::Buffer::::BEGIN@7KiokuDB::Collapser::Buffer::BEGIN@7
0000s0sKiokuDB::Collapser::Buffer::::__ANON__[:100]KiokuDB::Collapser::Buffer::__ANON__[:100]
0000s0sKiokuDB::Collapser::Buffer::::__ANON__[:106]KiokuDB::Collapser::Buffer::__ANON__[:106]
0000s0sKiokuDB::Collapser::Buffer::::__ANON__[:18]KiokuDB::Collapser::Buffer::__ANON__[:18]
0000s0sKiokuDB::Collapser::Buffer::::__ANON__[:37]KiokuDB::Collapser::Buffer::__ANON__[:37]
0000s0sKiokuDB::Collapser::Buffer::::__ANON__[:43]KiokuDB::Collapser::Buffer::__ANON__[:43]
0000s0sKiokuDB::Collapser::Buffer::::__ANON__[:60]KiokuDB::Collapser::Buffer::__ANON__[:60]
0000s0sKiokuDB::Collapser::Buffer::::__ANON__[:75]KiokuDB::Collapser::Buffer::__ANON__[:75]
0000s0sKiokuDB::Collapser::Buffer::::__ANON__[:92]KiokuDB::Collapser::Buffer::__ANON__[:92]
0000s0sKiokuDB::Collapser::Buffer::::commitKiokuDB::Collapser::Buffer::commit
0000s0sKiokuDB::Collapser::Buffer::::compact_dataKiokuDB::Collapser::Buffer::compact_data
0000s0sKiokuDB::Collapser::Buffer::::compact_entriesKiokuDB::Collapser::Buffer::compact_entries
0000s0sKiokuDB::Collapser::Buffer::::compact_entryKiokuDB::Collapser::Buffer::compact_entry
0000s0sKiokuDB::Collapser::Buffer::::id_to_entryKiokuDB::Collapser::Buffer::id_to_entry
0000s0sKiokuDB::Collapser::Buffer::::id_to_objectKiokuDB::Collapser::Buffer::id_to_object
0000s0sKiokuDB::Collapser::Buffer::::imply_rootKiokuDB::Collapser::Buffer::imply_root
0000s0sKiokuDB::Collapser::Buffer::::insertKiokuDB::Collapser::Buffer::insert
0000s0sKiokuDB::Collapser::Buffer::::insert_entryKiokuDB::Collapser::Buffer::insert_entry
0000s0sKiokuDB::Collapser::Buffer::::insert_intrinsicKiokuDB::Collapser::Buffer::insert_intrinsic
0000s0sKiokuDB::Collapser::Buffer::::insert_to_backendKiokuDB::Collapser::Buffer::insert_to_backend
0000s0sKiokuDB::Collapser::Buffer::::intrinsic_entryKiokuDB::Collapser::Buffer::intrinsic_entry
0000s0sKiokuDB::Collapser::Buffer::::merged_objects_to_idsKiokuDB::Collapser::Buffer::merged_objects_to_ids
0000s0sKiokuDB::Collapser::Buffer::::object_to_idKiokuDB::Collapser::Buffer::object_to_id
0000s0sKiokuDB::Collapser::Buffer::::update_entriesKiokuDB::Collapser::Buffer::update_entries
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package KiokuDB::Collapser::Buffer;
23224µs242.8ms
# spent 21.4ms (76µs+21.3) within KiokuDB::Collapser::Buffer::BEGIN@2 which was called: # once (76µs+21.3ms) by KiokuDB::Collapser::BEGIN@15 at line 2
use Moose;
# spent 21.4ms making 1 call to KiokuDB::Collapser::Buffer::BEGIN@2 # spent 21.3ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:456]
3
43118µs2393µs
# spent 338µs (124+214) within KiokuDB::Collapser::Buffer::BEGIN@4 which was called: # once (124µs+214µs) by KiokuDB::Collapser::BEGIN@15 at line 4
use Hash::Util::FieldHash::Compat qw(idhash);
# spent 338µs making 1 call to KiokuDB::Collapser::Buffer::BEGIN@4 # spent 55µs making 1 call to Hash::Util::FieldHash::Compat::import
53778µs217.5ms
# spent 17.4ms (13.6+3.81) within KiokuDB::Collapser::Buffer::BEGIN@5 which was called: # once (13.6ms+3.81ms) by KiokuDB::Collapser::BEGIN@15 at line 5
use Set::Object;
# spent 17.4ms making 1 call to KiokuDB::Collapser::Buffer::BEGIN@5 # spent 106µs making 1 call to Exporter::import
6
734.18ms23.18ms
# spent 1.61ms (44µs+1.57) within KiokuDB::Collapser::Buffer::BEGIN@7 which was called: # once (44µs+1.57ms) by KiokuDB::Collapser::BEGIN@15 at line 7
use namespace::clean -except => 'meta';
# spent 1.61ms making 1 call to KiokuDB::Collapser::Buffer::BEGIN@7 # spent 1.57ms making 1 call to namespace::clean::import
8
9114µs110.1mshas live_objects => (
# spent 10.1ms making 1 call to Moose::has
10 isa => "KiokuDB::LiveObjects",
11 is => "ro",
12 required => 1,
13);
14
15has _objects => (
16 isa => "HashRef",
17 is => "ro",
18 default => sub { idhash my %hash },
19121µs18.08ms);
# spent 8.08ms making 1 call to Moose::has
20
21sub object_to_id {
22 my ( $self, $object ) = @_;
23 $self->_objects->{$object};
24}
25
26sub merged_objects_to_ids {
27 my ( $self, @objects ) = @_;
28
29 my $l = $self->live_objects;
30
31 map { $self->object_to_id($_) || $l->object_to_id($_) } @objects;
32}
33
34has _ids => (
35 isa => "HashRef",
36 is => "ro",
37 default => sub { return {} },
38121µs17.74ms);
# spent 7.74ms making 1 call to Moose::has
39
40has _entry_args => (
41 isa => "HashRef",
42 is => "ro",
43 default => sub { return {} },
44120µs17.92ms);
# spent 7.92ms making 1 call to Moose::has
45
46sub id_to_object {
47 my ( $self, $id ) = @_;
48
49 if ( defined ( my $obj = $self->_ids->{$id} ) ) {
50 return $obj;
51 } else {
52 return $self->live_objects->id_to_object($id);
53 }
54}
55
56has entries => (
57 traits => ["Hash"],
58 isa => "HashRef",
59 reader => "_entries",
60 default => sub { return {} },
61133µs1371ms handles => {
# spent 371ms making 1 call to Moose::has
62 entries => "values",
63 ids => "keys",
64 },
65);
66
67sub id_to_entry {
68 my ( $self, $id ) = @_;
69 $self->_entries->{$id};
70}
71
72has intrinsic => (
73 isa => "HashRef",
74 is => "ro",
75 default => sub { idhash my %hash },
76120µs18.04ms);
# spent 8.04ms making 1 call to Moose::has
77
78sub intrinsic_entry {
79 my ( $self, $obj ) = @_;
80 $self->intrinsic->{$obj};
81}
82
83sub insert_intrinsic {
84 my ( $self, $object, $entry ) = @_;
85 $self->intrinsic->{$object} = $entry;
86}
87
88# a list of the IDs of all simple entries
89has simple_entries => (
90 isa => 'ArrayRef',
91 is => "ro",
92 default => sub { [] },
93122µs18.10ms);
# spent 8.10ms making 1 call to Moose::has
94
95# first_class keeps track of the simple references which are first class
96# (either weak or shared, and must have an entry)
97has first_class => (
98 isa => 'Set::Object',
99 is => "ro",
100 default => sub { Set::Object->new },
101121µs18.78ms);
# spent 8.78ms making 1 call to Moose::has
102
103has options => (
104 isa => 'HashRef',
105 is => "ro",
106 default => sub { {} },
107119µs18.14ms);
# spent 8.14ms making 1 call to Moose::has
108
109sub insert {
110 my ( $self, $id, $object, @args ) = @_;
111
112 $self->_objects->{$object} = $id;
113 $self->_ids->{$id} = $object;
114 $self->_entry_args->{$id} = \@args if @args;
115}
116
117sub insert_entry {
118 my ( $self, $id, $entry, $object, @args ) = @_;
119
120 $self->_entries->{$id} = $entry;
121 $self->insert($id, $object, @args);
122}
123
124sub compact_entries {
125 my $self = shift;
126
127 my ( $entries, $fc, $simple, $options ) = ( $self->_entries, $self->first_class, $self->simple_entries, $self->options );
128
129 # unify non shared simple references
130 if ( my @flatten = grep { not $fc->includes($_) } @$simple ) {
131 my %flatten;
132 @flatten{@flatten} = delete @{$entries}{@flatten};
133
134 $self->compact_entry($_, \%flatten) for values %$entries;
135 }
136}
137
138sub compact_entry {
139 my ( $self, $entry, $flatten ) = @_;
140
141 my $data = $entry->data;
142
143 if ( $self->compact_data($data, $flatten) ) {
144 $entry->_data($data);
145 }
146}
147
148sub compact_data {
149 my ( $self, $data, $flatten ) = @_;
150
151 if ( ref $data eq 'KiokuDB::Reference' ) {
152 my $id = $data->id;
153
154 if ( my $entry = $flatten->{$id} ) {
155 # replace reference with data from entry, so that the
156 # simple data is inlined, and mark that entry for removal
157 $self->compact_entry($entry, $flatten);
158
159 if ( $entry->tied or $entry->class ) {
160 $entry->clear_id;
161 $_[1] = $entry;
162 } else {
163 $_[1] = $entry->data;
164 }
165 return 1;
166 }
167 } elsif ( ref($data) eq 'ARRAY' ) {
168 ref && $self->compact_data($_, $flatten) for @$data;
169 } elsif ( ref($data) eq 'HASH' ) {
170 ref && $self->compact_data($_, $flatten) for values %$data;
171 } elsif ( ref($data) eq 'SCALAR' || ref($data) eq 'REF' ) {
172 $self->compact_data($$data, $flatten);
173 } elsif ( ref($data) eq 'KiokuDB::Entry' ) {
174 $self->compact_entry($data, $flatten);
175 } else {
176 # passthrough
177 }
178
179 return;
180}
181
182sub imply_root {
183 my ( $self, @ids ) = @_;
184
185 my $entries = $self->_entries;
186
187 foreach my $id ( @ids ) {
188 my $entry = $entries->{$id} or next;
189 next if $entry->has_root; # set by typemap
190 $entry->root(1);
191 }
192}
193
194sub commit {
195 my ( $self, $backend ) = @_;
196
197 $self->insert_to_backend($backend);
198 $self->update_entries( in_storage => 1 );
199}
200
201sub insert_to_backend {
202 my ( $self, $backend ) = @_;
203
204 $backend->insert(values %{ $self->_entries });
205}
206
207sub update_entries {
208 my ( $self, @shared_args ) = @_;
209
210 my ( $e, $o ) = ( $self->_entries, $self->_ids );
211
212 my $l = $self->live_objects;
213
214 my $args = $self->_entry_args;
215
216 foreach my $id ( keys %$e ) {
217 my ( $object, $entry ) = ( $o->{$id}, $e->{$id} );
218
219 my @args = @{ $args->{$id} || [] }; # FIXME XXX FIXME FIXME XXX BLAH BLAH
220
221 $l->register_entry( $id => $entry, @shared_args );
222
223 unless ( $l->object_to_id($object) ) {
224 $l->register_object( $id => $object, @args );
225 } else {
226 $l->update_object_entry( $object, $entry, @args );
227 }
228 }
229}
230
231125µs231.9ms__PACKAGE__->meta->make_immutable;
# spent 31.8ms making 1 call to Class::MOP::Class::make_immutable # spent 99µs making 1 call to KiokuDB::Collapser::Buffer::meta
232
233196µs__PACKAGE__
234
235169µs14.66ms__END__