← Index
NYTProf Performance Profile   « line view »
For /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/bin/perlcritic
  Run on Sat Mar 19 22:12:22 2016
Reported on Sat Mar 19 22:14:12 2016

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/File/HomeDir/Darwin/Cocoa.pm
StatementsExecuted 666 statements in 4.60ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111570µs1.50msFile::HomeDir::Darwin::Cocoa::::BEGIN@7File::HomeDir::Darwin::Cocoa::BEGIN@7
5551517µs3.77msFile::HomeDir::Darwin::Cocoa::::_find_folderFile::HomeDir::Darwin::Cocoa::_find_folder
5511214µs214µsFile::HomeDir::Darwin::Cocoa::::CORE:ftdirFile::HomeDir::Darwin::Cocoa::CORE:ftdir (opcode)
111150µs2.29msFile::HomeDir::Darwin::Cocoa::::my_desktopFile::HomeDir::Darwin::Cocoa::my_desktop
111148µs449µsFile::HomeDir::Darwin::Cocoa::::my_musicFile::HomeDir::Darwin::Cocoa::my_music
111148µs417µsFile::HomeDir::Darwin::Cocoa::::my_picturesFile::HomeDir::Darwin::Cocoa::my_pictures
111146µs407µsFile::HomeDir::Darwin::Cocoa::::my_videosFile::HomeDir::Darwin::Cocoa::my_videos
221146µs46µsFile::HomeDir::Darwin::Cocoa::::my_homeFile::HomeDir::Darwin::Cocoa::my_home
111145µs448µsFile::HomeDir::Darwin::Cocoa::::my_dataFile::HomeDir::Darwin::Cocoa::my_data
11139µs83µsFile::HomeDir::Darwin::Cocoa::::BEGIN@10File::HomeDir::Darwin::Cocoa::BEGIN@10
11116µs16µsFile::HomeDir::Darwin::Cocoa::::BEGIN@3File::HomeDir::Darwin::Cocoa::BEGIN@3
1118µs20µsFile::HomeDir::Darwin::Cocoa::::BEGIN@4File::HomeDir::Darwin::Cocoa::BEGIN@4
1118µs36µsFile::HomeDir::Darwin::Cocoa::::BEGIN@9File::HomeDir::Darwin::Cocoa::BEGIN@9
1114µs4µsFile::HomeDir::Darwin::Cocoa::::BEGIN@5File::HomeDir::Darwin::Cocoa::BEGIN@5
1113µs3µsFile::HomeDir::Darwin::Cocoa::::BEGIN@6File::HomeDir::Darwin::Cocoa::BEGIN@6
0000s0sFile::HomeDir::Darwin::Cocoa::::my_documentsFile::HomeDir::Darwin::Cocoa::my_documents
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package File::HomeDir::Darwin::Cocoa;
2
3240µs116µs
# spent 16µs within File::HomeDir::Darwin::Cocoa::BEGIN@3 which was called: # once (16µs+0s) by File::HomeDir::_DRIVER at line 3
use 5.00503;
# spent 16µs making 1 call to File::HomeDir::Darwin::Cocoa::BEGIN@3
4220µs233µs
# spent 20µs (8+13) within File::HomeDir::Darwin::Cocoa::BEGIN@4 which was called: # once (8µs+13µs) by File::HomeDir::_DRIVER at line 4
use strict;
# spent 20µs making 1 call to File::HomeDir::Darwin::Cocoa::BEGIN@4 # spent 13µs making 1 call to strict::import
5221µs14µs
# spent 4µs within File::HomeDir::Darwin::Cocoa::BEGIN@5 which was called: # once (4µs+0s) by File::HomeDir::_DRIVER at line 5
use Cwd ();
# spent 4µs making 1 call to File::HomeDir::Darwin::Cocoa::BEGIN@5
6215µs13µs
# spent 3µs within File::HomeDir::Darwin::Cocoa::BEGIN@6 which was called: # once (3µs+0s) by File::HomeDir::_DRIVER at line 6
use Carp ();
# spent 3µs making 1 call to File::HomeDir::Darwin::Cocoa::BEGIN@6
7280µs11.50ms
# spent 1.50ms (570µs+930µs) within File::HomeDir::Darwin::Cocoa::BEGIN@7 which was called: # once (570µs+930µs) by File::HomeDir::_DRIVER at line 7
use File::HomeDir::Darwin ();
# spent 1.50ms making 1 call to File::HomeDir::Darwin::Cocoa::BEGIN@7
8
9236µs264µs
# spent 36µs (8+28) within File::HomeDir::Darwin::Cocoa::BEGIN@9 which was called: # once (8µs+28µs) by File::HomeDir::_DRIVER at line 9
use vars qw{$VERSION @ISA};
# spent 36µs making 1 call to File::HomeDir::Darwin::Cocoa::BEGIN@9 # spent 28µs making 1 call to vars::import
10
# spent 83µs (39+44) within File::HomeDir::Darwin::Cocoa::BEGIN@10 which was called: # once (39µs+44µs) by File::HomeDir::_DRIVER at line 18
BEGIN {
111400ns $VERSION = '1.00';
1215µs @ISA = 'File::HomeDir::Darwin';
13
14 # Load early if in a forking environment and we have
15 # prefork, or at run-time if not.
161100ns local $@;
17122µs eval "use prefork 'Mac::SystemDirectory'";
# spent 55µs executing statements in string eval
# includes 44µs spent executing 1 call to 1 sub defined therein.
181284µs183µs}
# spent 83µs making 1 call to File::HomeDir::Darwin::Cocoa::BEGIN@10
19
- -
24#####################################################################
25# Current User Methods
26
27
# spent 46µs within File::HomeDir::Darwin::Cocoa::my_home which was called 22 times, avg 2µs/call: # 22 times (46µs+0s) by File::HomeDir::my_home at line 93 of File/HomeDir.pm, avg 2µs/call
sub my_home {
28225µs my $class = shift;
29
30 # A lot of unix people and unix-derived tools rely on
31 # the ability to overload HOME. We will support it too
32 # so that they can replace raw HOME calls with File::HomeDir.
332267µs if ( exists $ENV{HOME} and defined $ENV{HOME} ) {
34 return $ENV{HOME};
35 }
36
37 require Mac::SystemDirectory;
38 return Mac::SystemDirectory::HomeDirectory();
39}
40
41# from 10.4
42
# spent 2.29ms (50µs+2.24) within File::HomeDir::Darwin::Cocoa::my_desktop which was called 11 times, avg 208µs/call: # 11 times (50µs+2.24ms) by File::HomeDir::my_desktop at line 97 of File/HomeDir.pm, avg 208µs/call
sub my_desktop {
43113µs my $class = shift;
44
45113µs require Mac::SystemDirectory;
461122µs eval {
471116µs112.24ms $class->_find_folder(Mac::SystemDirectory::NSDesktopDirectory())
# spent 2.24ms making 11 calls to File::HomeDir::Darwin::Cocoa::_find_folder, avg 203µs/call
48 }
49 ||
50 $class->SUPER::my_desktop;
51}
52
53# from 10.2
54sub my_documents {
55 my $class = shift;
56
57 require Mac::SystemDirectory;
58 eval {
59 $class->_find_folder(Mac::SystemDirectory::NSDocumentDirectory())
60 }
61 ||
62 $class->SUPER::my_documents;
63}
64
65# from 10.4
66
# spent 448µs (45+403) within File::HomeDir::Darwin::Cocoa::my_data which was called 11 times, avg 41µs/call: # 11 times (45µs+403µs) by File::HomeDir::my_data at line 127 of File/HomeDir.pm, avg 41µs/call
sub my_data {
67113µs my $class = shift;
68
69113µs require Mac::SystemDirectory;
701121µs eval {
711112µs11403µs $class->_find_folder(Mac::SystemDirectory::NSApplicationSupportDirectory())
# spent 403µs making 11 calls to File::HomeDir::Darwin::Cocoa::_find_folder, avg 37µs/call
72 }
73 ||
74 $class->SUPER::my_data;
75}
76
77# from 10.6
78
# spent 449µs (48+400) within File::HomeDir::Darwin::Cocoa::my_music which was called 11 times, avg 41µs/call: # 11 times (48µs+400µs) by File::HomeDir::my_music at line 109 of File/HomeDir.pm, avg 41µs/call
sub my_music {
79114µs my $class = shift;
80
81114µs require Mac::SystemDirectory;
821121µs eval {
831113µs11400µs $class->_find_folder(Mac::SystemDirectory::NSMusicDirectory())
# spent 400µs making 11 calls to File::HomeDir::Darwin::Cocoa::_find_folder, avg 36µs/call
84 }
85 ||
86 $class->SUPER::my_music;
87}
88
89# from 10.6
90
# spent 417µs (48+369) within File::HomeDir::Darwin::Cocoa::my_pictures which was called 11 times, avg 38µs/call: # 11 times (48µs+369µs) by File::HomeDir::my_pictures at line 115 of File/HomeDir.pm, avg 38µs/call
sub my_pictures {
91114µs my $class = shift;
92
93113µs require Mac::SystemDirectory;
941119µs eval {
951113µs11369µs $class->_find_folder(Mac::SystemDirectory::NSPicturesDirectory())
# spent 369µs making 11 calls to File::HomeDir::Darwin::Cocoa::_find_folder, avg 34µs/call
96 }
97 ||
98 $class->SUPER::my_pictures;
99}
100
101# from 10.6
102
# spent 407µs (46+361) within File::HomeDir::Darwin::Cocoa::my_videos which was called 11 times, avg 37µs/call: # 11 times (46µs+361µs) by File::HomeDir::my_videos at line 121 of File/HomeDir.pm, avg 37µs/call
sub my_videos {
103113µs my $class = shift;
104
105113µs require Mac::SystemDirectory;
1061121µs eval {
1071113µs11361µs $class->_find_folder(Mac::SystemDirectory::NSMoviesDirectory())
# spent 361µs making 11 calls to File::HomeDir::Darwin::Cocoa::_find_folder, avg 33µs/call
108 }
109 ||
110 $class->SUPER::my_videos;
111}
112
113
# spent 3.77ms (517µs+3.25) within File::HomeDir::Darwin::Cocoa::_find_folder which was called 55 times, avg 69µs/call: # 11 times (124µs+2.11ms) by File::HomeDir::Darwin::Cocoa::my_desktop at line 47, avg 203µs/call # 11 times (98µs+306µs) by File::HomeDir::Darwin::Cocoa::my_data at line 71, avg 37µs/call # 11 times (100µs+300µs) by File::HomeDir::Darwin::Cocoa::my_music at line 83, avg 36µs/call # 11 times (98µs+271µs) by File::HomeDir::Darwin::Cocoa::my_pictures at line 95, avg 34µs/call # 11 times (98µs+263µs) by File::HomeDir::Darwin::Cocoa::my_videos at line 107, avg 33µs/call
sub _find_folder {
114557µs my $class = shift;
115556µs my $name = shift;
116
117558µs require Mac::SystemDirectory;
118552.90ms552.72ms my $folder = Mac::SystemDirectory::FindDirectory($name);
# spent 2.72ms making 55 calls to Mac::SystemDirectory::FindDirectory, avg 50µs/call
1195511µs return undef unless defined $folder;
120
12155311µs55214µs unless ( -d $folder ) {
# spent 214µs making 55 calls to File::HomeDir::Darwin::Cocoa::CORE:ftdir, avg 4µs/call
122 # Make sure that symlinks resolve to directories.
123 return undef unless -l $folder;
124 my $dir = readlink $folder or return;
125 return undef unless -d $dir;
126 }
127
12855554µs55313µs return Cwd::abs_path($folder);
# spent 313µs making 55 calls to Cwd::abs_path, avg 6µs/call
129}
130
13112µs1;
132
133=pod
134
135=head1 NAME
136
137File::HomeDir::Darwin::Cocoa - Find your home and other directories on Darwin (OS X)
138
139=head1 DESCRIPTION
140
141This module provides Darwin-specific implementations for determining
142common user directories using Cocoa API through
143L<Mac::SystemDirectory>. In normal usage this module will always be
144used via L<File::HomeDir>.
145
146Theoretically, this should return the same paths as both of the other
147Darwin drivers.
148
149Because this module requires L<Mac::SystemDirectory>, if the module
150is not installed, L<File::HomeDir> will fall back to L<File::HomeDir::Darwin>.
151
152=head1 SYNOPSIS
153
154 use File::HomeDir;
155
156 # Find directories for the current user
157 $home = File::HomeDir->my_home; # /Users/mylogin
158 $desktop = File::HomeDir->my_desktop; # /Users/mylogin/Desktop
159 $docs = File::HomeDir->my_documents; # /Users/mylogin/Documents
160 $music = File::HomeDir->my_music; # /Users/mylogin/Music
161 $pics = File::HomeDir->my_pictures; # /Users/mylogin/Pictures
162 $videos = File::HomeDir->my_videos; # /Users/mylogin/Movies
163 $data = File::HomeDir->my_data; # /Users/mylogin/Library/Application Support
164
165=cut
 
# spent 214µs within File::HomeDir::Darwin::Cocoa::CORE:ftdir which was called 55 times, avg 4µs/call: # 55 times (214µs+0s) by File::HomeDir::Darwin::Cocoa::_find_folder at line 121, avg 4µs/call
sub File::HomeDir::Darwin::Cocoa::CORE:ftdir; # opcode