← Index
NYTProf Performance Profile   « block view • line view • sub view »
For mentat.storage.mongo.pl
  Run on Tue Jun 24 09:58:41 2014
Reported on Tue Jun 24 09:59:12 2014

Filename/usr/local/share/perl/5.14.2/DateTime/TimeZone/OlsonDB/Change.pm
StatementsExecuted 10 statements in 1.58ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11117µs17µsDateTime::TimeZone::OlsonDB::Change::::BEGIN@5DateTime::TimeZone::OlsonDB::Change::BEGIN@5
11115µs22µsDateTime::TimeZone::OlsonDB::Change::::BEGIN@9DateTime::TimeZone::OlsonDB::Change::BEGIN@9
11115µs26µsDateTime::TimeZone::OlsonDB::Change::::BEGIN@10DateTime::TimeZone::OlsonDB::Change::BEGIN@10
11115µs105µsDateTime::TimeZone::OlsonDB::Change::::BEGIN@12DateTime::TimeZone::OlsonDB::Change::BEGIN@12
0000s0sDateTime::TimeZone::OlsonDB::Change::::_debug_outputDateTime::TimeZone::OlsonDB::Change::_debug_output
0000s0sDateTime::TimeZone::OlsonDB::Change::::is_dstDateTime::TimeZone::OlsonDB::Change::is_dst
0000s0sDateTime::TimeZone::OlsonDB::Change::::local_start_datetimeDateTime::TimeZone::OlsonDB::Change::local_start_datetime
0000s0sDateTime::TimeZone::OlsonDB::Change::::newDateTime::TimeZone::OlsonDB::Change::new
0000s0sDateTime::TimeZone::OlsonDB::Change::::observanceDateTime::TimeZone::OlsonDB::Change::observance
0000s0sDateTime::TimeZone::OlsonDB::Change::::offset_from_stdDateTime::TimeZone::OlsonDB::Change::offset_from_std
0000s0sDateTime::TimeZone::OlsonDB::Change::::offset_from_utcDateTime::TimeZone::OlsonDB::Change::offset_from_utc
0000s0sDateTime::TimeZone::OlsonDB::Change::::ruleDateTime::TimeZone::OlsonDB::Change::rule
0000s0sDateTime::TimeZone::OlsonDB::Change::::short_nameDateTime::TimeZone::OlsonDB::Change::short_name
0000s0sDateTime::TimeZone::OlsonDB::Change::::total_offsetDateTime::TimeZone::OlsonDB::Change::total_offset
0000s0sDateTime::TimeZone::OlsonDB::Change::::two_changes_as_spanDateTime::TimeZone::OlsonDB::Change::two_changes_as_span
0000s0sDateTime::TimeZone::OlsonDB::Change::::utc_start_datetimeDateTime::TimeZone::OlsonDB::Change::utc_start_datetime
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package DateTime::TimeZone::OlsonDB::Change;
2{
322µs $DateTime::TimeZone::OlsonDB::Change::VERSION = '1.63';
4}
5
# spent 17µs within DateTime::TimeZone::OlsonDB::Change::BEGIN@5 which was called: # once (17µs+0s) by DateTime::TimeZone::OlsonDB::Zone::BEGIN@14 at line 7
BEGIN {
6111µs $DateTime::TimeZone::OlsonDB::Change::AUTHORITY = 'cpan:DROLSKY';
7141µs117µs}
# spent 17µs making 1 call to DateTime::TimeZone::OlsonDB::Change::BEGIN@5
8
9260µs228µs
# spent 22µs (15+6) within DateTime::TimeZone::OlsonDB::Change::BEGIN@9 which was called: # once (15µs+6µs) by DateTime::TimeZone::OlsonDB::Zone::BEGIN@14 at line 9
use strict;
# spent 22µs making 1 call to DateTime::TimeZone::OlsonDB::Change::BEGIN@9 # spent 6µs making 1 call to strict::import
10257µs236µs
# spent 26µs (15+11) within DateTime::TimeZone::OlsonDB::Change::BEGIN@10 which was called: # once (15µs+11µs) by DateTime::TimeZone::OlsonDB::Zone::BEGIN@14 at line 10
use warnings;
# spent 26µs making 1 call to DateTime::TimeZone::OlsonDB::Change::BEGIN@10 # spent 11µs making 1 call to warnings::import
11
1221.40ms2195µs
# spent 105µs (15+90) within DateTime::TimeZone::OlsonDB::Change::BEGIN@12 which was called: # once (15µs+90µs) by DateTime::TimeZone::OlsonDB::Zone::BEGIN@14 at line 12
use Params::Validate qw( validate SCALAR UNDEF OBJECT );
# spent 105µs making 1 call to DateTime::TimeZone::OlsonDB::Change::BEGIN@12 # spent 90µs making 1 call to Exporter::import
13
14sub new {
15 my $class = shift;
16 my %p = validate(
17 @_, {
18 utc_start_datetime => { type => UNDEF | OBJECT },
19 local_start_datetime => { type => UNDEF | OBJECT },
20 short_name => { type => SCALAR },
21 observance => { type => OBJECT },
22 rule => { type => OBJECT, default => undef },
23 type => {
24 type => SCALAR,
25 regex => qr/^(?:observance|rule)$/
26 },
27 }
28 );
29
30 # These are almost always mutually exclusive, except when adding
31 # an observance change and the last rule has no offset, but the
32 # new observance has an anonymous rule. In that case, prefer the
33 # offset from std defined in the observance to that in the
34 # previous rule (what a mess!).
35 if ( $p{type} eq 'observance' ) {
36 $p{offset_from_std} = $p{rule}->offset_from_std if defined $p{rule};
37 $p{offset_from_std} = $p{observance}->offset_from_std
38 if $p{observance}->offset_from_std;
39 $p{offset_from_std} ||= 0;
40 }
41 else {
42 $p{offset_from_std} = $p{observance}->offset_from_std;
43 $p{offset_from_std} = $p{rule}->offset_from_std if defined $p{rule};
44 }
45
46 $p{offset_from_utc} = $p{observance}->offset_from_utc;
47
48 $p{is_dst} = 0;
49 $p{is_dst} = 1 if $p{rule} && $p{rule}->offset_from_std;
50 $p{is_dst} = 1 if $p{observance}->offset_from_std;
51
52 if ( $p{short_name} =~ m{(\w+)/(\w+)} ) {
53 $p{short_name} = $p{is_dst} ? $2 : $1;
54 }
55
56 return bless \%p, $class;
57}
58
59sub utc_start_datetime { $_[0]->{utc_start_datetime} }
60sub local_start_datetime { $_[0]->{local_start_datetime} }
61sub short_name { $_[0]->{short_name} }
62sub is_dst { $_[0]->{is_dst} }
63sub observance { $_[0]->{observance} }
64sub rule { $_[0]->{rule} }
65sub offset_from_utc { $_[0]->{offset_from_utc} }
66sub offset_from_std { $_[0]->{offset_from_std} }
67sub total_offset { $_[0]->offset_from_utc + $_[0]->offset_from_std }
68
69sub two_changes_as_span {
70 my ( $c1, $c2, $last_total_offset ) = @_;
71
72 my ( $utc_start, $local_start );
73
74 if ( defined $c1->utc_start_datetime ) {
75 $utc_start = $c1->utc_start_datetime->utc_rd_as_seconds;
76 $local_start = $c1->local_start_datetime->utc_rd_as_seconds;
77 }
78 else {
79 $utc_start = $local_start = '-inf';
80 }
81
82 my $utc_end = $c2->utc_start_datetime->utc_rd_as_seconds;
83 my $local_end = $utc_end + $c1->total_offset;
84
85 return {
86 utc_start => $utc_start,
87 utc_end => $utc_end,
88 local_start => $local_start,
89 local_end => $local_end,
90 short_name => $c1->short_name,
91 offset => $c1->total_offset,
92 is_dst => $c1->is_dst,
93 };
94}
95
96sub _debug_output {
97 my $self = shift;
98
99 my $obs = $self->observance;
100
101 if ( $self->utc_start_datetime ) {
102 print " UTC: ", $self->utc_start_datetime->datetime, "\n";
103 print " Local: ", $self->local_start_datetime->datetime, "\n";
104 }
105 else {
106 print " First change (starts at -inf)\n";
107 }
108
109 print " Short name: ", $self->short_name, "\n";
110 print " UTC offset: ", $obs->offset_from_utc, "\n";
111
112 if ( $obs->offset_from_std || $self->rule ) {
113 if ( $obs->offset_from_std ) {
114 print " Std offset: ", $obs->offset_from_std, "\n";
115 }
116
117 if ( $self->rule ) {
118 print " Std offset: ", $self->rule->offset_from_std, ' - ',
119 $self->rule->name, " rule\n";
120 }
121 }
122 else {
123 print " Std offset: 0 - no rule\n";
124 }
125
126 print "\n";
127}
128
12916µs1;