| Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/DateTime/Format/SQLite.pm |
| Statements | Executed 1196 statements in 7.76ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 294 | 2 | 2 | 7.83ms | 77.9ms | DateTime::Format::SQLite::format_datetime |
| 1 | 1 | 1 | 2.85ms | 9.82ms | DateTime::Format::SQLite::BEGIN@16 |
| 1 | 1 | 1 | 20µs | 26µs | DateTime::Format::SQLite::BEGIN@5 |
| 1 | 1 | 1 | 15µs | 32µs | DateTime::Format::SQLite::BEGIN@7 |
| 7 | 1 | 1 | 12µs | 12µs | DateTime::Format::SQLite::CORE:qr (opcode) |
| 1 | 1 | 1 | 10µs | 37µs | DateTime::Format::SQLite::BEGIN@6 |
| 0 | 0 | 0 | 0s | 0s | DateTime::Format::SQLite::__ANON__[:60] |
| 0 | 0 | 0 | 0s | 0s | DateTime::Format::SQLite::__ANON__[:68] |
| 0 | 0 | 0 | 0s | 0s | DateTime::Format::SQLite::_fix_nanoseconds |
| 0 | 0 | 0 | 0s | 0s | DateTime::Format::SQLite::format_date |
| 0 | 0 | 0 | 0s | 0s | DateTime::Format::SQLite::format_julianday |
| 0 | 0 | 0 | 0s | 0s | DateTime::Format::SQLite::format_time |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | # $Id: SQLite.pm 4363 2009-12-10 16:47:25Z cfaerber $ | ||||
| 2 | # | ||||
| 3 | package DateTime::Format::SQLite; | ||||
| 4 | |||||
| 5 | 3 | 29µs | 2 | 31µs | # spent 26µs (20+6) within DateTime::Format::SQLite::BEGIN@5 which was called:
# once (20µs+6µs) by Class::C3::Componentised::ensure_class_loaded at line 5 # spent 26µs making 1 call to DateTime::Format::SQLite::BEGIN@5
# spent 6µs making 1 call to strict::import |
| 6 | 3 | 21µs | 2 | 65µs | # spent 37µs (10+27) within DateTime::Format::SQLite::BEGIN@6 which was called:
# once (10µs+27µs) by Class::C3::Componentised::ensure_class_loaded at line 6 # spent 37µs making 1 call to DateTime::Format::SQLite::BEGIN@6
# spent 27µs making 1 call to vars::import |
| 7 | 3 | 353µs | 2 | 49µs | # spent 32µs (15+17) within DateTime::Format::SQLite::BEGIN@7 which was called:
# once (15µs+17µs) by Class::C3::Componentised::ensure_class_loaded at line 7 # spent 32µs making 1 call to DateTime::Format::SQLite::BEGIN@7
# spent 17µs making 1 call to warnings::import |
| 8 | |||||
| 9 | 1 | 600ns | our $VERSION = '0.11'; | ||
| 10 | 2 | 2µs | $VERSION = eval { $VERSION }; | ||
| 11 | |||||
| 12 | # "days since noon in Greenwich on November 24, 4714 B.C." | ||||
| 13 | 1 | 4µs | my %jd0 = ( 'year' => -4713, 'month' => 11, 'day' => 24, 'hour' => 12, time_zone => 'UTC' ); | ||
| 14 | |||||
| 15 | use DateTime::Format::Builder | ||||
| 16 | # spent 9.82ms (2.85+6.97) within DateTime::Format::SQLite::BEGIN@16 which was called:
# once (2.85ms+6.97ms) by Class::C3::Componentised::ensure_class_loaded at line 72 | ||||
| 17 | { parse_datetime => | ||||
| 18 | [ | ||||
| 19 | # format 1 | ||||
| 20 | # | ||||
| 21 | { params => [ qw( year month day ) ], | ||||
| 22 | regex => qr/^(-?\d+)-(\d+)-(\d+)$/, | ||||
| 23 | extra => { time_zone => 'UTC' }, | ||||
| 24 | }, | ||||
| 25 | |||||
| 26 | # formats 2 and 5 | ||||
| 27 | # | ||||
| 28 | { params => [ qw( year month day hour minute ) ], | ||||
| 29 | regex => qr/^(-?\d+)-(\d{1,2})-(\d{1,2})[Tt ](\d{1,2}):(\d{1,2})$/, | ||||
| 30 | extra => { time_zone => 'UTC' }, | ||||
| 31 | }, | ||||
| 32 | |||||
| 33 | # formats 3, 4, 6 and 7 | ||||
| 34 | # | ||||
| 35 | { params => [ qw( year month day hour minute second nanosecond ) ], | ||||
| 36 | regex => qr/^(-?\d+)-(\d{1,2})-(\d{1,2})[Tt ](\d{1,2}):(\d{1,2}):(\d{1,2})(\.\d*)?$/, | ||||
| 37 | extra => { time_zone => 'UTC' }, | ||||
| 38 | postprocess => \&_fix_nanoseconds, | ||||
| 39 | }, | ||||
| 40 | |||||
| 41 | # format 8 | ||||
| 42 | # | ||||
| 43 | { params => [ qw( hour minute ) ], | ||||
| 44 | regex => qr/^(\d{1,2}):(\d{1,2})$/, | ||||
| 45 | extra => { time_zone => 'UTC', 'year' => 2000, }, | ||||
| 46 | }, | ||||
| 47 | |||||
| 48 | # format 9, 10 | ||||
| 49 | # | ||||
| 50 | { params => [ qw( hour minute second nanosecond ) ], | ||||
| 51 | regex => qr/^(\d{1,2}):(\d{1,2}):(\d{1,2})(\.\d*)?$/, | ||||
| 52 | extra => { time_zone => 'UTC', 'year' => 2000, }, | ||||
| 53 | postprocess => \&_fix_nanoseconds, | ||||
| 54 | }, | ||||
| 55 | |||||
| 56 | # format 11 | ||||
| 57 | # | ||||
| 58 | { params => [ qw ( dummy ) ], | ||||
| 59 | regex => qr/^([Nn][Oo][Ww])$/, | ||||
| 60 | constructor => sub { return DateTime->now }, | ||||
| 61 | }, | ||||
| 62 | |||||
| 63 | # format 12 | ||||
| 64 | # | ||||
| 65 | { params => [ qw( jd secs ) ], | ||||
| 66 | regex => qr/^(\d+(\.\d*)?)$/, | ||||
| 67 | constructor => sub { shift; my %p=(@_); return DateTime->new(%jd0)->add( | ||||
| 68 | 'days' => int($p{'jd'}), 'seconds' => ($p{'secs'} || 0) * (3600 * 24) ); }, | ||||
| 69 | }, | ||||
| 70 | 8 | 1.59ms | ] # spent 1.57ms making 1 call to DateTime::Format::Builder::import
# spent 12µs making 7 calls to DateTime::Format::SQLite::CORE:qr, avg 2µs/call | ||
| 71 | }, | ||||
| 72 | 3 | 381µs | 1 | 9.82ms | ); # spent 9.82ms making 1 call to DateTime::Format::SQLite::BEGIN@16 |
| 73 | |||||
| 74 | 1 | 1µs | *parse_date = \&parse_datetime; | ||
| 75 | 1 | 600ns | *parse_time = \&parse_datetime; | ||
| 76 | 1 | 400ns | *parse_julianday = \&parse_datetime; | ||
| 77 | |||||
| 78 | sub format_date | ||||
| 79 | { | ||||
| 80 | my ( $self, $dt ) = @_; | ||||
| 81 | |||||
| 82 | $dt = $dt->clone; | ||||
| 83 | $dt->set_time_zone('UTC'); | ||||
| 84 | |||||
| 85 | return $dt->ymd('-'); | ||||
| 86 | } | ||||
| 87 | |||||
| 88 | sub format_time | ||||
| 89 | { | ||||
| 90 | my ( $self, $dt ) = @_; | ||||
| 91 | |||||
| 92 | $dt = $dt->clone; | ||||
| 93 | $dt->set_time_zone('UTC'); | ||||
| 94 | |||||
| 95 | return $dt->hms(':'); | ||||
| 96 | } | ||||
| 97 | |||||
| 98 | sub format_datetime | ||||
| 99 | # spent 77.9ms (7.83+70.0) within DateTime::Format::SQLite::format_datetime which was called 294 times, avg 265µs/call:
# 147 times (5.01ms+36.1ms) by Tapper::MCP::Scheduler::Controller::mark_job_as_running at line 135 of lib/Tapper/MCP/Scheduler/Controller.pm, avg 280µs/call
# 147 times (2.82ms+33.9ms) by DBIx::Class::InflateColumn::DateTime::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/DBIx/Class/InflateColumn/DateTime.pm:202] at line 201 of DBIx/Class/InflateColumn/DateTime.pm, avg 250µs/call | ||||
| 100 | 1176 | 6.96ms | my ( $self, $dt ) = @_; | ||
| 101 | |||||
| 102 | 294 | 3.94ms | $dt = $dt->clone; # spent 3.94ms making 294 calls to DateTime::clone, avg 13µs/call | ||
| 103 | 294 | 59.5ms | $dt->set_time_zone('UTC'); # spent 59.5ms making 294 calls to DateTime::set_time_zone, avg 202µs/call | ||
| 104 | |||||
| 105 | 588 | 6.63ms | return join ' ', $dt->ymd('-'), $dt->hms(':'); # spent 4.61ms making 294 calls to DateTime::ymd, avg 16µs/call
# spent 2.02ms making 294 calls to DateTime::hms, avg 7µs/call | ||
| 106 | } | ||||
| 107 | |||||
| 108 | |||||
| 109 | sub format_julianday | ||||
| 110 | { | ||||
| 111 | my ( $self, $dt ) = @_; | ||||
| 112 | |||||
| 113 | return $dt->jd; | ||||
| 114 | } | ||||
| 115 | |||||
| 116 | sub _fix_nanoseconds | ||||
| 117 | { | ||||
| 118 | my %args = @_; | ||||
| 119 | $args{'parsed'}->{'nanosecond'} ||= 0; | ||||
| 120 | $args{'parsed'}->{'nanosecond'} *= 1000 * 1000 * 1000; | ||||
| 121 | 1; | ||||
| 122 | } | ||||
| 123 | |||||
| 124 | 1 | 6µs | 1; | ||
| 125 | |||||
| 126 | __END__ | ||||
# spent 12µs within DateTime::Format::SQLite::CORE:qr which was called 7 times, avg 2µs/call:
# 7 times (12µs+0s) by DateTime::Format::SQLite::BEGIN@16 at line 70, avg 2µs/call |