← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Sun Aug 5 15:24:32 2012
Reported on Sun Aug 5 15:24:49 2012

Filename/usr/lib/perl5/site_perl/5.12.1/DateTime/TimeZone/Local.pm
StatementsExecuted 19 statements in 2.95ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1119.40ms10.3msDateTime::TimeZone::Local::::BEGIN@10DateTime::TimeZone::Local::BEGIN@10
11182µs108µsDateTime::TimeZone::Local::::BEGIN@3DateTime::TimeZone::Local::BEGIN@3
11177µs170µsDateTime::TimeZone::Local::::BEGIN@4DateTime::TimeZone::Local::BEGIN@4
11149µs196µsDateTime::TimeZone::Local::::BEGIN@6DateTime::TimeZone::Local::BEGIN@6
11133µs33µsDateTime::TimeZone::Local::::BEGIN@9DateTime::TimeZone::Local::BEGIN@9
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;
2
33158µs2134µs
# spent 108µs (82+26) within DateTime::TimeZone::Local::BEGIN@3 which was called: # once (82µs+26µs) by DateTime::TimeZone::BEGIN@12 at line 3
use strict;
# spent 108µs making 1 call to DateTime::TimeZone::Local::BEGIN@3 # spent 26µs making 1 call to strict::import
43147µs2262µs
# spent 170µs (77+93) within DateTime::TimeZone::Local::BEGIN@4 which was called: # once (77µs+93µs) by DateTime::TimeZone::BEGIN@12 at line 4
use warnings;
# spent 170µs making 1 call to DateTime::TimeZone::Local::BEGIN@4 # spent 92µs making 1 call to warnings::import
5
63173µs2343µs
# spent 196µs (49+147) within DateTime::TimeZone::Local::BEGIN@6 which was called: # once (49µs+147µs) by DateTime::TimeZone::BEGIN@12 at line 6
use vars qw( $VERSION );
# spent 196µs making 1 call to DateTime::TimeZone::Local::BEGIN@6 # spent 147µs making 1 call to vars::import
717µs$VERSION = '0.01';
8
93134µs133µs
# spent 33µs within DateTime::TimeZone::Local::BEGIN@9 which was called: # once (33µs+0s) by DateTime::TimeZone::BEGIN@12 at line 9
use DateTime::TimeZone;
# spent 33µs making 1 call to DateTime::TimeZone::Local::BEGIN@9
1032.27ms110.3ms
# spent 10.3ms (9.40+859µs) within DateTime::TimeZone::Local::BEGIN@10 which was called: # once (9.40ms+859µs) by DateTime::TimeZone::BEGIN@12 at line 10
use File::Spec;
# spent 10.3ms making 1 call to DateTime::TimeZone::Local::BEGIN@10
11
12sub TimeZone {
13 my $class = shift;
14
15 my $subclass = $class->_load_subclass();
16
17 for my $meth ( $subclass->Methods() ) {
18 my $tz = $subclass->$meth();
19
20 return $tz if $tz;
21 }
22
23 die "Cannot determine local time zone\n";
24}
25
26{
27 # Stolen from File::Spec. My theory is that other folks can write
28 # the non-existent modules if they feel a need, and release them
29 # to CPAN separately.
30233µs my %subclass = (
31 MSWin32 => 'Win32',
32 VMS => 'VMS',
33 MacOS => 'Mac',
34 os2 => 'OS2',
35 epoc => 'Epoc',
36 NetWare => 'Win32',
37 symbian => 'Win32',
38 dos => 'OS2',
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 local $@;
51 local $SIG{__DIE__};
52 eval "use $subclass";
53 if ( my $e = $@ ) {
54 if ( $e =~ /locate.+$os_name/ ) {
55 $subclass = $class . '::' . 'Unix';
56
57 eval "use $subclass";
58 my $e2 = $@;
59 die $e2 if $e2;
60 }
61 else {
62 die $e;
63 }
64 }
65
66 return $subclass;
67 }
68}
69
70sub FromEnv {
71 my $class = shift;
72
73 foreach my $var ( $class->EnvVars() ) {
74 if ( $class->_IsValidName( $ENV{$var} ) ) {
75 my $tz;
76 {
77 local $@;
78 local $SIG{__DIE__};
79 $tz = eval { DateTime::TimeZone->new( name => $ENV{$var} ) };
80 }
81 return $tz if $tz;
82 }
83 }
84
85 return;
86}
87
88sub _IsValidName {
89 shift;
90
91 return 0 unless defined $_[0];
92 return 0 if $_[0] eq 'local';
93
94 return $_[0] =~ m{^[\w/\-\+]+$};
95}
96
97126µs1;
98
99__END__