← 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:00 2012

Filename/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/DBIx/Class/TimeStamp.pm
StatementsExecuted 227 statements in 392µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
444175µs8.88msDBIx::Class::TimeStamp::::add_columnsDBIx::Class::TimeStamp::add_columns
11114µs70µsDBIx::Class::TimeStamp::::BEGIN@3DBIx::Class::TimeStamp::BEGIN@3
1118µs17µsDBIx::Class::TimeStamp::::BEGIN@5DBIx::Class::TimeStamp::BEGIN@5
1117µs9µsDBIx::Class::TimeStamp::::BEGIN@6DBIx::Class::TimeStamp::BEGIN@6
1116µs6µsDBIx::Class::TimeStamp::::BEGIN@8DBIx::Class::TimeStamp::BEGIN@8
0000s0sDBIx::Class::TimeStamp::::get_timestampDBIx::Class::TimeStamp::get_timestamp
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package DBIx::Class::TimeStamp;
2
3321µs2126µs
# spent 70µs (14+56) within DBIx::Class::TimeStamp::BEGIN@3 which was called: # once (14µs+56µs) by Class::C3::Componentised::ensure_class_loaded at line 3
use base qw(DBIx::Class);
# spent 70µs making 1 call to DBIx::Class::TimeStamp::BEGIN@3 # spent 56µs making 1 call to base::import
4
5318µs227µs
# spent 17µs (8+9) within DBIx::Class::TimeStamp::BEGIN@5 which was called: # once (8µs+9µs) by Class::C3::Componentised::ensure_class_loaded at line 5
use warnings;
# spent 17µs making 1 call to DBIx::Class::TimeStamp::BEGIN@5 # spent 9µs making 1 call to warnings::import
6318µs211µs
# spent 9µs (7+2) within DBIx::Class::TimeStamp::BEGIN@6 which was called: # once (7µs+2µs) by Class::C3::Componentised::ensure_class_loaded at line 6
use strict;
# spent 9µs making 1 call to DBIx::Class::TimeStamp::BEGIN@6 # spent 2µs making 1 call to strict::import
7
83160µs16µs
# spent 6µs within DBIx::Class::TimeStamp::BEGIN@8 which was called: # once (6µs+0s) by Class::C3::Componentised::ensure_class_loaded at line 8
use DateTime;
# spent 6µs making 1 call to DBIx::Class::TimeStamp::BEGIN@8
9
101600nsour $VERSION = '0.14';
11
1218µs10s__PACKAGE__->load_components( qw/DynamicDefault InflateColumn::DateTime/ );
# spent 1.27ms making 1 call to Class::C3::Componentised::load_components, recursion: max depth 1, sum of overlapping time 1.27ms
13
14=head1 NAME
15
16DBIx::Class::TimeStamp - DBIx::Class extension to update and create date and time based fields
17
18=head1 DESCRIPTION
19
20Works in conjunction with InflateColumn::DateTime to automatically set update
21and create date and time based fields in a table.
22
23=head1 SYNOPSIS
24
25 package My::Schema;
26
27 __PACKAGE__->load_components(qw( TimeStamp ... Core ));
28
29 __PACKAGE__->add_columns(
30 id => { data_type => 'integer' },
31 t_created => { data_type => 'datetime', set_on_create => 1 },
32 t_updated => { data_type => 'datetime',
33 set_on_create => 1, set_on_update => 1 },
34 );
35
36Now, any update or create actions will update the specified columns with the
37current time, using the DateTime inflator.
38
39This is effectively trigger emulation to get consistent behavior across
40databases that either implement them poorly or not at all.
41
42=cut
43
44
# spent 8.88ms (175µs+8.71) within DBIx::Class::TimeStamp::add_columns which was called 4 times, avg 2.22ms/call: # once (72µs+4.18ms) by Class::C3::Componentised::ensure_class_loaded at line 19 of Tapper/Schema/ReportsDB/Result/Report.pm # once (37µs+1.79ms) by Class::C3::Componentised::ensure_class_loaded at line 17 of Tapper/Schema/ReportsDB/Result/ReportFile.pm # once (33µs+1.54ms) by Class::C3::Componentised::ensure_class_loaded at line 19 of Tapper/Schema/ReportsDB/Result/Tap.pm # once (33µs+1.20ms) by Class::C3::Componentised::ensure_class_loaded at line 16 of Tapper/Schema/ReportsDB/Result/ReportComment.pm
sub add_columns {
45416µs my ($self, @cols) = @_;
4642µs my @columns;
47
48429µs while (my $col = shift @cols) {
494718µs my $info = ref $cols[0] ? shift @cols : {};
50
514720µs if ( delete $info->{set_on_create} ) {
52 $info->{dynamic_default_on_create} = 'get_timestamp';
53 }
54
554713µs if ( delete $info->{set_on_update} ) {
5643µs $info->{dynamic_default_on_update} = 'get_timestamp';
57
5846µs if ( defined $info->{dynamic_default_on_create} and
59 $info->{dynamic_default_on_create} eq 'get_timestamp'
60 ) {
61 $info->{dynamic_default_on_update} = 'get_timestamp';
62 }
63 }
64
654727µs push @columns, $col => $info;
66 }
67
68430µs439µs return $self->next::method(@columns);
# spent 39µs making 4 calls to next::method, avg 10µs/call
69}
70
71=head1 METHODS
72
73=head2 get_timestamp
74
75Returns a DateTime object pointing to now. Override this method if you have
76different time accounting functions, or want to do anything special.
77
78The date and time objects in the database are expected to be inflated. As such
79you can be pretty flexible with what you want to return here.
80
81=cut
82
83sub get_timestamp {
84 return DateTime->now
85}
86
87=head1 AUTHOR
88
89J. Shirley <jshirley@gmail.com>
90
91=head1 CONTRIBUTORS
92
93Florian Ragwitz (Porting to L<DBIx::Class::DynamicDefault>)
94
95LTJake/bricas
96
97=head1 COPYRIGHT & LICENSE
98
99Copyright 2009 J. Shirley, all rights reserved.
100
101This program is free software; you can redistribute it and/or modify it
102under the same terms as Perl itself.
103
104=cut
105
10615µs1;
107