← Index
NYTProf Performance Profile   « block view • line view • sub view »
For mentat.storage.mongo.pl
  Run on Tue Jun 24 10:04:38 2014
Reported on Tue Jun 24 10:05:34 2014

Filename/usr/local/lib/perl/5.14.2/MongoDB/DBRef.pm
StatementsExecuted 21 statements in 473µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11113µs3.51msMongoDB::DBRef::::BEGIN@24MongoDB::DBRef::BEGIN@24
1118µs1.59msMongoDB::DBRef::::BEGIN@25MongoDB::DBRef::BEGIN@25
1117µs32µsMongoDB::DBRef::::BEGIN@26MongoDB::DBRef::BEGIN@26
1115µs5µsMongoDB::DBRef::::BEGIN@27MongoDB::DBRef::BEGIN@27
0000s0sMongoDB::DBRef::::__ANON__[:35]MongoDB::DBRef::__ANON__[:35]
0000s0sMongoDB::DBRef::::__ANON__[:39]MongoDB::DBRef::__ANON__[:39]
0000s0sMongoDB::DBRef::::_orderedMongoDB::DBRef::_ordered
0000s0sMongoDB::DBRef::::fetchMongoDB::DBRef::fetch
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1#
2# Copyright 2009-2013 MongoDB, Inc.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17package MongoDB::DBRef;
18{
1921µs $MongoDB::DBRef::VERSION = '0.702.2';
20}
21
22# ABSTRACT: Native DBRef support
23
24234µs27.00ms
# spent 3.51ms (13µs+3.50) within MongoDB::DBRef::BEGIN@24 which was called: # once (13µs+3.50ms) by MongoDB::BEGIN@32 at line 24
use Moose;
# spent 3.51ms making 1 call to MongoDB::DBRef::BEGIN@24 # spent 3.50ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:519]
25233µs23.17ms
# spent 1.59ms (8µs+1.58) within MongoDB::DBRef::BEGIN@25 which was called: # once (8µs+1.58ms) by MongoDB::BEGIN@32 at line 25
use Moose::Util::TypeConstraints;
# spent 1.59ms making 1 call to MongoDB::DBRef::BEGIN@25 # spent 1.58ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:519]
26224µs257µs
# spent 32µs (7+25) within MongoDB::DBRef::BEGIN@26 which was called: # once (7µs+25µs) by MongoDB::BEGIN@32 at line 26
use Carp 'croak';
# spent 32µs making 1 call to MongoDB::DBRef::BEGIN@26 # spent 25µs making 1 call to Exporter::import
272337µs15µs
# spent 5µs within MongoDB::DBRef::BEGIN@27 which was called: # once (5µs+0s) by MongoDB::BEGIN@32 at line 27
use Tie::IxHash;
# spent 5µs making 1 call to MongoDB::DBRef::BEGIN@27
28
29
3016µs2492µssubtype DBRefColl => as 'Str';
# spent 487µs making 1 call to Moose::Util::TypeConstraints::subtype # spent 5µs making 1 call to Moose::Util::TypeConstraints::as
3114µs2445µssubtype DBRefDB => as 'Str';
# spent 443µs making 1 call to Moose::Util::TypeConstraints::subtype # spent 2µs making 1 call to Moose::Util::TypeConstraints::as
32
33coerce 'DBRefColl'
34 => from 'MongoDB::Collection'
3517µs3396µs => via { $_->name };
# spent 391µs making 1 call to Moose::Util::TypeConstraints::coerce # spent 2µs making 1 call to Moose::Util::TypeConstraints::from # spent 2µs making 1 call to Moose::Util::TypeConstraints::via
36
37coerce 'DBRefDB'
38 => from 'MongoDB::Database'
3914µs3239µs => via { $_->name };
# spent 237µs making 1 call to Moose::Util::TypeConstraints::coerce # spent 1µs making 1 call to Moose::Util::TypeConstraints::from # spent 1µs making 1 call to Moose::Util::TypeConstraints::via
40
41
42# no type constraint since an _id can be anything
4312µs11.51mshas id => (
# spent 1.51ms making 1 call to Moose::has
44 is => 'rw',
45 required => 1
46);
47
4812µs12.15mshas ref => (
# spent 2.15ms making 1 call to Moose::has
49 is => 'rw',
50 isa => 'DBRefColl',
51 required => 1,
52 coerce => 1,
53);
54
5512µs12.08mshas db => (
# spent 2.08ms making 1 call to Moose::has
56 is => 'rw',
57 isa => 'DBRefDB',
58 required => 1,
59 coerce => 1,
60);
61
6212µs11.66mshas client => (
# spent 1.66ms making 1 call to Moose::has
63 is => 'rw',
64 isa => 'MongoDB::MongoClient',
65 required => 0
66);
67
6812µs11.65mshas verify_db => (
# spent 1.65ms making 1 call to Moose::has
69 is => 'rw',
70 isa => 'Bool',
71 required => 0,
72 default => 1
73);
74
7511µs11.67mshas verify_coll => (
# spent 1.67ms making 1 call to Moose::has
76 is => 'rw',
77 isa => 'Bool',
78 required => 0,
79 default => 1
80);
81
82
83sub fetch {
84 my $self = shift;
85
86 my $client = $self->client;
87
88 croak "Can't fetch DBRef without a MongoClient. Specify a 'client' attribute."
89 unless $client;
90
91 my $db = $self->db;
92
93 if ( $self->verify_db ) {
94 croak sprintf "No such database %s", $db
95 unless grep { $_ eq $db } $client->database_names;
96 }
97
98 my $ref = $self->ref;
99
100 if ( $self->verify_coll ) {
101 croak sprintf "No such collection %s", $ref
102 unless grep { $_ eq $ref } $client->get_database( $db )->collection_names;
103 }
104
105 my $id = $self->id;
106
107 return $client->get_database( $db )->get_collection( $ref )->find_one( { _id => $id } );
108}
109
110sub _ordered {
111 my $self = shift;
112
113 return Tie::IxHash->new( '$ref' => $self->ref, '$id' => $self->id, '$db' => $self->db );
114}
115
116113µs1;
117
118__END__