← Index
NYTProf Performance Profile   « line view »
For svc/members/upsert
  Run on Tue Jan 13 11:50:22 2015
Reported on Tue Jan 13 12:09:47 2015

Filename/usr/share/perl5/DateTime/TimeZone/Local.pm
StatementsExecuted 14 statements in 2.00ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1113.84ms4.69msDateTime::TimeZone::Local::::BEGIN@8DateTime::TimeZone::Local::BEGIN@8
1111.76ms20.4msDateTime::TimeZone::Local::::BEGIN@6DateTime::TimeZone::Local::BEGIN@6
11112µs24µsDateTime::TimeZone::Local::::BEGIN@3DateTime::TimeZone::Local::BEGIN@3
1118µs8µsDateTime::TimeZone::Local::::BEGIN@7DateTime::TimeZone::Local::BEGIN@7
1117µs11µsDateTime::TimeZone::Local::::BEGIN@4DateTime::TimeZone::Local::BEGIN@4
0000s0sDateTime::TimeZone::Local::::FromEnvDateTime::TimeZone::Local::FromEnv
0000s0sDateTime::TimeZone::Local::::TimeZoneDateTime::TimeZone::Local::TimeZone
0000s0sDateTime::TimeZone::Local::::_IsValidNameDateTime::TimeZone::Local::_IsValidName
0000s0sDateTime::TimeZone::Local::::_load_subclassDateTime::TimeZone::Local::_load_subclass
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::Local;
21500ns$DateTime::TimeZone::Local::VERSION = '1.75';
3225µs236µs
# spent 24µs (12+12) within DateTime::TimeZone::Local::BEGIN@3 which was called: # once (12µs+12µs) by DateTime::TimeZone::BEGIN@12 at line 3
use strict;
# spent 24µs making 1 call to DateTime::TimeZone::Local::BEGIN@3 # spent 12µs making 1 call to strict::import
4226µs216µs
# spent 11µs (7+4) within DateTime::TimeZone::Local::BEGIN@4 which was called: # once (7µs+4µs) by DateTime::TimeZone::BEGIN@12 at line 4
use warnings;
# spent 11µs making 1 call to DateTime::TimeZone::Local::BEGIN@4 # spent 4µs making 1 call to warnings::import
5
62740µs220.5ms
# spent 20.4ms (1.76+18.7) within DateTime::TimeZone::Local::BEGIN@6 which was called: # once (1.76ms+18.7ms) by DateTime::TimeZone::BEGIN@12 at line 6
use Class::Load qw( is_class_loaded load_class try_load_class );
# spent 20.4ms making 1 call to DateTime::TimeZone::Local::BEGIN@6 # spent 37µs making 1 call to Exporter::import
7223µs18µs
# spent 8µs within DateTime::TimeZone::Local::BEGIN@7 which was called: # once (8µs+0s) by DateTime::TimeZone::BEGIN@12 at line 7
use DateTime::TimeZone;
# spent 8µs making 1 call to DateTime::TimeZone::Local::BEGIN@7
821.18ms14.69ms
# spent 4.69ms (3.84+849µs) within DateTime::TimeZone::Local::BEGIN@8 which was called: # once (3.84ms+849µs) by DateTime::TimeZone::BEGIN@12 at line 8
use File::Spec;
# spent 4.69ms making 1 call to DateTime::TimeZone::Local::BEGIN@8
9
10sub TimeZone {
11 my $class = shift;
12
13 my $subclass = $class->_load_subclass();
14
15 for my $meth ( $subclass->Methods() ) {
16 my $tz = $subclass->$meth();
17
18 return $tz if $tz;
19 }
20
21 die "Cannot determine local time zone\n";
22}
23
24{
25 # Stolen from File::Spec. My theory is that other folks can write
26 # the non-existent modules if they feel a need, and release them
27 # to CPAN separately.
2825µs my %subclass = (
29 MSWin32 => 'Win32',
30 VMS => 'VMS',
31 MacOS => 'Mac',
32 os2 => 'OS2',
33 epoc => 'Epoc',
34 NetWare => 'Win32',
35 symbian => 'Win32',
36 dos => 'OS2',
37 android => 'Android',
38 cygwin => 'Unix',
39 );
40
41 sub _load_subclass {
42 my $class = shift;
43
44 my $os_name = $subclass{$^O} || $^O;
45 my $subclass = $class . '::' . $os_name;
46
47 return $subclass if is_class_loaded($subclass);
48
49 return $subclass if try_load_class($subclass);
50
51 $subclass = $class . '::Unix';
52
53 load_class($subclass);
54
55 return $subclass;
56 }
57}
58
59sub FromEnv {
60 my $class = shift;
61
62 foreach my $var ( $class->EnvVars() ) {
63 if ( $class->_IsValidName( $ENV{$var} ) ) {
64 my $tz;
65 {
66 local $@;
67 local $SIG{__DIE__};
68 $tz = eval { DateTime::TimeZone->new( name => $ENV{$var} ) };
69 }
70 return $tz if $tz;
71 }
72 }
73
74 return;
75}
76
77sub _IsValidName {
78 shift;
79
80 return 0 unless defined $_[0];
81 return 0 if $_[0] eq 'local';
82
83 return $_[0] =~ m{^[\w/\-\+]+$};
84}
85
8614µs1;
87
88# ABSTRACT: Determine the local system's time zone
89
90__END__