← Index
NYTProf Performance Profile   « block view • line view • sub view »
For mongo_pain.pl
  Run on Fri Mar 25 17:00:29 2011
Reported on Fri Mar 25 17:07:06 2011

Filename/usr/local/share/perl/5.10.1/DateTime/TimeZone/Local.pm
StatementsExecuted 19 statements in 741µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.16ms3.99msDateTime::TimeZone::Local::::BEGIN@9DateTime::TimeZone::Local::BEGIN@9
11112µs12µsDateTime::TimeZone::Local::::BEGIN@2DateTime::TimeZone::Local::BEGIN@2
11110µs22µsDateTime::TimeZone::Local::::BEGIN@7DateTime::TimeZone::Local::BEGIN@7
11110µs14µsDateTime::TimeZone::Local::::BEGIN@6DateTime::TimeZone::Local::BEGIN@6
1118µs8µsDateTime::TimeZone::Local::::BEGIN@10DateTime::TimeZone::Local::BEGIN@10
1116µs6µsDateTime::TimeZone::Local::::BEGIN@11DateTime::TimeZone::Local::BEGIN@11
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
# spent 12µs within DateTime::TimeZone::Local::BEGIN@2 which was called: # once (12µs+0s) by DateTime::TimeZone::BEGIN@13 at line 4
BEGIN {
316µs $DateTime::TimeZone::Local::VERSION = '1.31';
4128µs112µs}
# spent 12µs making 1 call to DateTime::TimeZone::Local::BEGIN@2
5
6332µs218µs
# spent 14µs (10+4) within DateTime::TimeZone::Local::BEGIN@6 which was called: # once (10µs+4µs) by DateTime::TimeZone::BEGIN@13 at line 6
use strict;
# spent 14µs making 1 call to DateTime::TimeZone::Local::BEGIN@6 # spent 4µs making 1 call to strict::import
7338µs234µs
# spent 22µs (10+12) within DateTime::TimeZone::Local::BEGIN@7 which was called: # once (10µs+12µs) by DateTime::TimeZone::BEGIN@13 at line 7
use warnings;
# spent 22µs making 1 call to DateTime::TimeZone::Local::BEGIN@7 # spent 12µs making 1 call to warnings::import
8
93114µs24.06ms
# spent 3.99ms (1.16+2.83) within DateTime::TimeZone::Local::BEGIN@9 which was called: # once (1.16ms+2.83ms) by DateTime::TimeZone::BEGIN@13 at line 9
use Class::Load qw( is_class_loaded load_class try_load_class );
# spent 3.99ms making 1 call to DateTime::TimeZone::Local::BEGIN@9 # spent 65µs making 1 call to Exporter::import
10334µs18µs
# spent 8µs within DateTime::TimeZone::Local::BEGIN@10 which was called: # once (8µs+0s) by DateTime::TimeZone::BEGIN@13 at line 10
use DateTime::TimeZone;
# spent 8µs making 1 call to DateTime::TimeZone::Local::BEGIN@10
113476µs16µs
# spent 6µs within DateTime::TimeZone::Local::BEGIN@11 which was called: # once (6µs+0s) by DateTime::TimeZone::BEGIN@13 at line 11
use File::Spec;
# spent 6µs making 1 call to DateTime::TimeZone::Local::BEGIN@11
12
13sub TimeZone {
14 my $class = shift;
15
16 my $subclass = $class->_load_subclass();
17
18 for my $meth ( $subclass->Methods() ) {
19 my $tz = $subclass->$meth();
20
21 return $tz if $tz;
22 }
23
24 die "Cannot determine local time zone\n";
25}
26
27{
28 # Stolen from File::Spec. My theory is that other folks can write
29 # the non-existent modules if they feel a need, and release them
30 # to CPAN separately.
3127µs my %subclass = (
32 MSWin32 => 'Win32',
33 VMS => 'VMS',
34 MacOS => 'Mac',
35 os2 => 'OS2',
36 epoc => 'Epoc',
37 NetWare => 'Win32',
38 symbian => 'Win32',
39 dos => 'OS2',
40 cygwin => 'Unix',
41 );
42
43 sub _load_subclass {
44 my $class = shift;
45
46 my $os_name = $subclass{$^O} || $^O;
47 my $subclass = $class . '::' . $os_name;
48
49 return $subclass if is_class_loaded($subclass);
50
51 return $subclass if try_load_class($subclass);
52
53 $subclass = $class . '::Unix';
54
55 load_class($subclass);
56
57 return $subclass;
58 }
59}
60
61sub FromEnv {
62 my $class = shift;
63
64 foreach my $var ( $class->EnvVars() ) {
65 if ( $class->_IsValidName( $ENV{$var} ) ) {
66 my $tz;
67 {
68 local $@;
69 local $SIG{__DIE__};
70 $tz = eval { DateTime::TimeZone->new( name => $ENV{$var} ) };
71 }
72 return $tz if $tz;
73 }
74 }
75
76 return;
77}
78
79sub _IsValidName {
80 shift;
81
82 return 0 unless defined $_[0];
83 return 0 if $_[0] eq 'local';
84
85 return $_[0] =~ m{^[\w/\-\+]+$};
86}
87
8816µs1;
89
90# ABSTRACT: Determine the local system's time zone
91
- -
94=pod
95
- -
207__END__