← Index
NYTProf Performance Profile   « block view • line view • sub view »
For xt/tapper-mcp-scheduler-with-db-longrun.t
  Run on Tue May 22 17:18:39 2012
Reported on Tue May 22 17:24:06 2012

Filename/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/SQL/Translator/Schema/View.pm
StatementsExecuted 111 statements in 675µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
21136µs102µsSQL::Translator::Schema::View::::fieldsSQL::Translator::Schema::View::fields
42118µs22µsSQL::Translator::Schema::View::::orderSQL::Translator::Schema::View::order
11117µs20µsSQL::Translator::Schema::View::::BEGIN@44SQL::Translator::Schema::View::BEGIN@44
63313µs13µsSQL::Translator::Schema::View::::nameSQL::Translator::Schema::View::name
42213µs13µsSQL::Translator::Schema::View::::sqlSQL::Translator::Schema::View::sql
21111µs12µsSQL::Translator::Schema::View::::schemaSQL::Translator::Schema::View::schema
1118µs34µsSQL::Translator::Schema::View::::BEGIN@45SQL::Translator::Schema::View::BEGIN@45
1117µs70µsSQL::Translator::Schema::View::::BEGIN@47SQL::Translator::Schema::View::BEGIN@47
1116µs44µsSQL::Translator::Schema::View::::BEGIN@49SQL::Translator::Schema::View::BEGIN@49
2113µs3µsSQL::Translator::Schema::View::::CORE:matchSQL::Translator::Schema::View::CORE:match (opcode)
0000s0sSQL::Translator::Schema::View::::DESTROYSQL::Translator::Schema::View::DESTROY
0000s0sSQL::Translator::Schema::View::::equalsSQL::Translator::Schema::View::equals
0000s0sSQL::Translator::Schema::View::::is_validSQL::Translator::Schema::View::is_valid
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package SQL::Translator::Schema::View;
2
3# ----------------------------------------------------------------------
4# Copyright (C) 2002-2009 SQLFairy Authors
5#
6# This program is free software; you can redistribute it and/or
7# modify it under the terms of the GNU General Public License as
8# published by the Free Software Foundation; version 2.
9#
10# This program is distributed in the hope that it will be useful, but
11# WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18# 02111-1307 USA
19# -------------------------------------------------------------------
20
21=pod
22
23=head1 NAME
24
25SQL::Translator::Schema::View - SQL::Translator view object
26
27=head1 SYNOPSIS
28
29 use SQL::Translator::Schema::View;
30 my $view = SQL::Translator::Schema::View->new(
31 name => 'foo', # name, required
32 sql => 'select id, name from foo', # SQL for view
33 fields => 'id, name', # field names in view
34 );
35
36=head1 DESCRIPTION
37
38C<SQL::Translator::Schema::View> is the view object.
39
40=head1 METHODS
41
42=cut
43
44320µs223µs
# spent 20µs (17+3) within SQL::Translator::Schema::View::BEGIN@44 which was called: # once (17µs+3µs) by SQL::Translator::Schema::BEGIN@52 at line 44
use strict;
# spent 20µs making 1 call to SQL::Translator::Schema::View::BEGIN@44 # spent 3µs making 1 call to strict::import
45320µs260µs
# spent 34µs (8+26) within SQL::Translator::Schema::View::BEGIN@45 which was called: # once (8µs+26µs) by SQL::Translator::Schema::BEGIN@52 at line 45
use SQL::Translator::Utils 'parse_list_arg';
# spent 34µs making 1 call to SQL::Translator::Schema::View::BEGIN@45 # spent 26µs making 1 call to Exporter::import
46
47324µs2134µs
# spent 70µs (7+63) within SQL::Translator::Schema::View::BEGIN@47 which was called: # once (7µs+63µs) by SQL::Translator::Schema::BEGIN@52 at line 47
use base 'SQL::Translator::Schema::Object';
# spent 70µs making 1 call to SQL::Translator::Schema::View::BEGIN@47 # spent 63µs making 1 call to base::import
48
493484µs281µs
# spent 44µs (6+37) within SQL::Translator::Schema::View::BEGIN@49 which was called: # once (6µs+37µs) by SQL::Translator::Schema::BEGIN@52 at line 49
use vars qw($VERSION $TABLE_COUNT $VIEW_COUNT);
# spent 44µs making 1 call to SQL::Translator::Schema::View::BEGIN@49 # spent 37µs making 1 call to vars::import
50
511700ns$VERSION = '1.59';
52
53# ----------------------------------------------------------------------
54
5515µs139µs__PACKAGE__->_attributes( qw/
# spent 39µs making 1 call to SQL::Translator::Schema::Object::_attributes
56 name sql fields schema order
57/);
58
59=pod
60
61=head2 new
62
63Object constructor.
64
65 my $view = SQL::Translator::Schema::View->new;
66
67=cut
68
69# ----------------------------------------------------------------------
70
# spent 102µs (36+65) within SQL::Translator::Schema::View::fields which was called 2 times, avg 51µs/call: # 2 times (36µs+65µs) by SQL::Translator::Schema::Object::init at line 104 of SQL/Translator/Schema/Object.pm, avg 51µs/call
sub fields {
71
72=pod
73
74=head2 fields
75
76Gets and set the fields the constraint is on. Accepts a string, list or
77arrayref; returns an array or array reference. Will unique the field
78names and keep them in order by the first occurrence of a field name.
79
80 $view->fields('id');
81 $view->fields('id', 'name');
82 $view->fields( 'id, name' );
83 $view->fields( [ 'id', 'name' ] );
84 $view->fields( qw[ id name ] );
85
86 my @fields = $view->fields;
87
88=cut
89
902900ns my $self = shift;
9124µs266µs my $fields = parse_list_arg( @_ );
# spent 66µs making 2 calls to SQL::Translator::Utils::parse_list_arg, avg 33µs/call
92
9321µs if ( @$fields ) {
942700ns my ( %unique, @unique );
9521µs for my $f ( @$fields ) {
96102µs next if $unique{ $f };
97107µs $unique{ $f } = 1;
98109µs push @unique, $f;
99 }
100
10122µs $self->{'fields'} = \@unique;
102 }
103
10426µs return wantarray ? @{ $self->{'fields'} || [] } : ($self->{'fields'} || '');
105}
106
107# ----------------------------------------------------------------------
108sub is_valid {
109
110=pod
111
112=head2 is_valid
113
114Determine whether the view is valid or not.
115
116 my $ok = $view->is_valid;
117
118=cut
119
120 my $self = shift;
121
122 return $self->error('No name') unless $self->name;
123 return $self->error('No sql') unless $self->sql;
124
125 return 1;
126}
127
128# ----------------------------------------------------------------------
129
# spent 13µs within SQL::Translator::Schema::View::name which was called 6 times, avg 2µs/call: # 2 times (5µs+0s) by SQL::Translator::Schema::Object::init at line 104 of SQL/Translator/Schema/Object.pm, avg 3µs/call # 2 times (5µs+0s) by SQL::Translator::Producer::SQLite::create_view at line 135 of SQL/Translator/Producer/SQLite.pm, avg 2µs/call # 2 times (3µs+0s) by SQL::Translator::Schema::add_view at line 424 of SQL/Translator/Schema.pm, avg 2µs/call
sub name {
130
131=pod
132
133=head2 name
134
135Get or set the view's name.
136
137 my $name = $view->name('foo');
138
139=cut
140
14162µs my $self = shift;
14263µs $self->{'name'} = shift if @_;
143617µs return $self->{'name'} || '';
144}
145
146# ----------------------------------------------------------------------
147
# spent 22µs (18+3) within SQL::Translator::Schema::View::order which was called 4 times, avg 5µs/call: # 2 times (13µs+3µs) by SQL::Translator::Schema::add_view at line 423 of SQL/Translator/Schema.pm, avg 8µs/call # 2 times (6µs+0s) by SQL::Translator::Schema::get_views at line 701 of SQL/Translator/Schema.pm, avg 3µs/call
sub order {
148
149=pod
150
151=head2 order
152
153Get or set the view's order.
154
155 my $order = $view->order(3);
156
157=cut
158
15942µs my ( $self, $arg ) = @_;
160
161412µs23µs if ( defined $arg && $arg =~ /^\d+$/ ) {
# spent 3µs making 2 calls to SQL::Translator::Schema::View::CORE:match, avg 2µs/call
162 $self->{'order'} = $arg;
163 }
164
165414µs return $self->{'order'} || 0;
166}
167
168# ----------------------------------------------------------------------
169
# spent 13µs within SQL::Translator::Schema::View::sql which was called 4 times, avg 3µs/call: # 2 times (8µs+0s) by SQL::Translator::Schema::Object::init at line 104 of SQL/Translator/Schema/Object.pm, avg 4µs/call # 2 times (5µs+0s) by SQL::Translator::Producer::SQLite::create_view at line 149 of SQL/Translator/Producer/SQLite.pm, avg 3µs/call
sub sql {
170
171=pod
172
173=head2 sql
174
175Get or set the view's SQL.
176
177 my $sql = $view->sql('select * from foo');
178
179=cut
180
18141µs my $self = shift;
18242µs $self->{'sql'} = shift if @_;
183414µs return $self->{'sql'} || '';
184}
185
186# ----------------------------------------------------------------------
187
# spent 12µs (11+1) within SQL::Translator::Schema::View::schema which was called 2 times, avg 6µs/call: # 2 times (11µs+1µs) by SQL::Translator::Schema::Object::init at line 104 of SQL/Translator/Schema/Object.pm, avg 6µs/call
sub schema {
188
189=pod
190
191=head2 schema
192
193Get or set the view's schema object.
194
195 $view->schema( $schema );
196 my $schema = $view->schema;
197
198=cut
199
2002900ns my $self = shift;
20121µs if ( my $arg = shift ) {
20226µs22µs return $self->error('Not a schema object') unless
# spent 2µs making 2 calls to UNIVERSAL::isa, avg 750ns/call
203 UNIVERSAL::isa( $arg, 'SQL::Translator::Schema' );
20421µs $self->{'schema'} = $arg;
205 }
206
20725µs return $self->{'schema'};
208}
209
210# ----------------------------------------------------------------------
211sub equals {
212
213=pod
214
215=head2 equals
216
217Determines if this view is the same as another
218
219 my $isIdentical = $view1->equals( $view2 );
220
221=cut
222
223 my $self = shift;
224 my $other = shift;
225 my $case_insensitive = shift;
226 my $ignore_sql = shift;
227
228 return 0 unless $self->SUPER::equals($other);
229 return 0 unless $case_insensitive ? uc($self->name) eq uc($other->name) : $self->name eq $other->name;
230 #return 0 unless $self->is_valid eq $other->is_valid;
231
232 unless ($ignore_sql) {
233 my $selfSql = $self->sql;
234 my $otherSql = $other->sql;
235 # Remove comments
236 $selfSql =~ s/--.*$//mg;
237 $otherSql =~ s/--.*$//mg;
238 # Collapse whitespace to space to avoid whitespace comparison issues
239 $selfSql =~ s/\s+/ /sg;
240 $otherSql =~ s/\s+/ /sg;
241 return 0 unless $selfSql eq $otherSql;
242 }
243
244 my $selfFields = join(":", $self->fields);
245 my $otherFields = join(":", $other->fields);
246 return 0 unless $case_insensitive ? uc($selfFields) eq uc($otherFields) : $selfFields eq $otherFields;
247 return 0 unless $self->_compare_objects(scalar $self->extra, scalar $other->extra);
248 return 1;
249}
250
251# ----------------------------------------------------------------------
252sub DESTROY {
253 my $self = shift;
254 undef $self->{'schema'}; # destroy cyclical reference
255}
256
25713µs1;
258
259# ----------------------------------------------------------------------
260
261=pod
262
263=head1 AUTHOR
264
265Ken Youens-Clark E<lt>kclark@cpan.orgE<gt>.
266
267=cut
 
# spent 3µs within SQL::Translator::Schema::View::CORE:match which was called 2 times, avg 2µs/call: # 2 times (3µs+0s) by SQL::Translator::Schema::View::order at line 161, avg 2µs/call
sub SQL::Translator::Schema::View::CORE:match; # opcode