← Index
NYTProf Performance Profile   « line view »
For -e
  Run on Thu Jun 30 16:16:00 2016
Reported on Thu Jun 30 16:16:08 2016

Filename/home/s1/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/DateTime/TimeZone/Local.pm
StatementsExecuted 16 statements in 1.48ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1113.19ms4.19msDateTime::TimeZone::Local::::BEGIN@7DateTime::TimeZone::Local::BEGIN@7
11131µs35µsDateTime::TimeZone::Local::::BEGIN@3DateTime::TimeZone::Local::BEGIN@3
11114µs22µsDateTime::TimeZone::Local::::BEGIN@4DateTime::TimeZone::Local::BEGIN@4
11114µs34µsDateTime::TimeZone::Local::::BEGIN@8DateTime::TimeZone::Local::BEGIN@8
11112µs56µsDateTime::TimeZone::Local::::BEGIN@9DateTime::TimeZone::Local::BEGIN@9
1118µs8µsDateTime::TimeZone::Local::::BEGIN@6DateTime::TimeZone::Local::BEGIN@6
0000s0sDateTime::TimeZone::Local::::FromEnvDateTime::TimeZone::Local::FromEnv
0000s0sDateTime::TimeZone::Local::::TimeZoneDateTime::TimeZone::Local::TimeZone
0000s0sDateTime::TimeZone::Local::::_IsValidNameDateTime::TimeZone::Local::_IsValidName
0000s0sDateTime::TimeZone::Local::::__ANON__[:53]DateTime::TimeZone::Local::__ANON__[:53]
0000s0sDateTime::TimeZone::Local::::__ANON__[:71]DateTime::TimeZone::Local::__ANON__[:71]
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;
211µs$DateTime::TimeZone::Local::VERSION = '1.98';
3238µs239µs
# spent 35µs (31+4) within DateTime::TimeZone::Local::BEGIN@3 which was called: # once (31µs+4µs) by DateTime::TimeZone::BEGIN@10 at line 3
use strict;
# spent 35µs making 1 call to DateTime::TimeZone::Local::BEGIN@3 # spent 4µs making 1 call to strict::import
4232µs229µs
# spent 22µs (14+8) within DateTime::TimeZone::Local::BEGIN@4 which was called: # once (14µs+8µs) by DateTime::TimeZone::BEGIN@10 at line 4
use warnings;
# spent 22µs making 1 call to DateTime::TimeZone::Local::BEGIN@4 # spent 8µs making 1 call to warnings::import
5
6230µs18µs
# spent 8µs within DateTime::TimeZone::Local::BEGIN@6 which was called: # once (8µs+0s) by DateTime::TimeZone::BEGIN@10 at line 6
use DateTime::TimeZone;
# spent 8µs making 1 call to DateTime::TimeZone::Local::BEGIN@6
72445µs14.19ms
# spent 4.19ms (3.19+1.00) within DateTime::TimeZone::Local::BEGIN@7 which was called: # once (3.19ms+1.00ms) by DateTime::TimeZone::BEGIN@10 at line 7
use File::Spec;
# spent 4.19ms making 1 call to DateTime::TimeZone::Local::BEGIN@7
8236µs255µs
# spent 34µs (14+21) within DateTime::TimeZone::Local::BEGIN@8 which was called: # once (14µs+21µs) by DateTime::TimeZone::BEGIN@10 at line 8
use Module::Runtime qw( require_module );
# spent 34µs making 1 call to DateTime::TimeZone::Local::BEGIN@8 # spent 20µs making 1 call to Module::Runtime::import
92886µs2100µs
# spent 56µs (12+44) within DateTime::TimeZone::Local::BEGIN@9 which was called: # once (12µs+44µs) by DateTime::TimeZone::BEGIN@10 at line 9
use Try::Tiny;
# spent 56µs making 1 call to DateTime::TimeZone::Local::BEGIN@9 # spent 44µs making 1 call to Exporter::import
10
11sub TimeZone {
12 my $class = shift;
13
14 my $subclass = $class->_load_subclass();
15
16 for my $meth ( $subclass->Methods() ) {
17 my $tz = $subclass->$meth();
18
19 return $tz if $tz;
20 }
21
22 die "Cannot determine local time zone\n";
23}
24
25{
26 # Stolen from File::Spec. My theory is that other folks can write
27 # the non-existent modules if they feel a need, and release them
28 # to CPAN separately.
2918µs my %subclass = (
30 MSWin32 => 'Win32',
31 VMS => 'VMS',
32 MacOS => 'Mac',
33 os2 => 'OS2',
34 epoc => 'Epoc',
35 NetWare => 'Win32',
36 symbian => 'Win32',
37 dos => 'OS2',
38 android => 'Android',
39 cygwin => 'Unix',
40 );
41
42 sub _load_subclass {
43 my $class = shift;
44
45 my $os_name = $subclass{$^O} || $^O;
46 my $subclass = $class . '::' . $os_name;
47
48 return $subclass if $subclass->can('Methods');
49
50 return $subclass if try {
51 local $SIG{__DIE__};
52 require_module($subclass);
53 };
54
55 $subclass = $class . '::Unix';
56
57 require_module($subclass);
58
59 return $subclass;
60 }
61}
62
631600nssub FromEnv {
64 my $class = shift;
65
66 foreach my $var ( $class->EnvVars() ) {
67 if ( $class->_IsValidName( $ENV{$var} ) ) {
68 my $tz = try {
69 local $SIG{__DIE__};
70 DateTime::TimeZone->new( name => $ENV{$var} );
71 };
72
73 return $tz if $tz;
74 }
75 }
76
77 return;
78}
79
80sub _IsValidName {
81 shift;
82
83 return 0 unless defined $_[0];
84 return 0 if $_[0] eq 'local';
85
86 return $_[0] =~ m{^[\w/\-\+]+$};
87}
88
8916µs1;
90
91# ABSTRACT: Determine the local system's time zone
92
93__END__