Filename | /home/hinrik/perl5/perlbrew/perls/perl-5.13.5/lib/site_perl/5.13.5/Dir/Self.pm |
Statements | Executed 21 statements in 997µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 1.90ms | 2.12ms | BEGIN@6 | Dir::Self::
1 | 1 | 1 | 30µs | 3.78ms | __DIR__ | Dir::Self::
1 | 1 | 1 | 28µs | 28µs | BEGIN@3 | Dir::Self::
1 | 1 | 1 | 20µs | 20µs | import | Dir::Self::
1 | 1 | 1 | 12µs | 38µs | BEGIN@36 | Dir::Self::
1 | 1 | 1 | 12µs | 18µs | BEGIN@4 | Dir::Self::
1 | 1 | 1 | 11µs | 33µs | BEGIN@39 | Dir::Self::
0 | 0 | 0 | 0s | 0s | __ANON__[:25] | Dir::Self::
0 | 0 | 0 | 0s | 0s | _const | Dir::Self::
0 | 0 | 0 | 0s | 0s | _croak | Dir::Self::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | 1 | 57µs | 3 | 62µs | package Dir::Self; # spent 54µs making 1 call to Encode::utf8::decode_xs
# spent 4µs making 1 call to Encode::Encoding::renewed
# spent 3µs making 1 call to Encode::utf8::encode_xs |
2 | |||||
3 | 2 | 86µs | 3 | 57µs | # spent 28µs within Dir::Self::BEGIN@3 which was called:
# once (28µs+0s) by hailo::BEGIN@5 at line 3 # spent 28µs making 1 call to Dir::Self::BEGIN@3
# spent 26µs making 1 call to Encode::utf8::decode_xs
# spent 3µs making 1 call to Encode::Encoding::renewed |
4 | 2 | 26µs | 3 | 26µs | # spent 18µs (12+6) within Dir::Self::BEGIN@4 which was called:
# once (12µs+6µs) by hailo::BEGIN@5 at line 4 # spent 18µs making 1 call to Dir::Self::BEGIN@4
# spent 6µs making 1 call to strict::import
# spent 2µs making 1 call to Encode::utf8::encode_xs |
5 | |||||
6 | 2 | 215µs | 4 | 2.16ms | # spent 2.12ms (1.90+228µs) within Dir::Self::BEGIN@6 which was called:
# once (1.90ms+228µs) by hailo::BEGIN@5 at line 6 # spent 2.12ms making 1 call to Dir::Self::BEGIN@6
# spent 26µs making 1 call to Encode::utf8::decode_xs
# spent 9µs making 1 call to Encode::utf8::encode_xs
# spent 4µs making 1 call to Encode::Encoding::renewed |
7 | |||||
8 | 1 | 50µs | 3 | 39µs | *VERSION = \'0.10'; # spent 31µs making 1 call to Encode::utf8::decode_xs
# spent 6µs making 1 call to Encode::Encoding::renewed
# spent 2µs making 1 call to Encode::utf8::encode_xs |
9 | |||||
10 | 1 | 71µs | 2 | 29µs | sub _croak { # spent 26µs making 1 call to Encode::utf8::decode_xs
# spent 3µs making 1 call to Encode::Encoding::renewed |
11 | require Carp; | ||||
12 | local $^W = 0; | ||||
13 | *_croak = \&Carp::croak; | ||||
14 | goto &Carp::croak; | ||||
15 | 1 | 3µs | } # spent 3µs making 1 call to Encode::utf8::encode_xs | ||
16 | |||||
17 | 1 | 81µs | 2 | 30µs | # spent 3.78ms (30µs+3.75) within Dir::Self::__DIR__ which was called:
# once (30µs+3.75ms) by main::RUNTIME at line 29 of bin/hailo # spent 26µs making 1 call to Encode::utf8::decode_xs
# spent 4µs making 1 call to Encode::Encoding::renewed |
18 | 3 | 28µs | my $level = shift || 0; | ||
19 | my $file = (caller $level)[1]; | ||||
20 | 2 | 3.75ms | File::Spec->rel2abs(join '', (File::Spec->splitpath($file))[0, 1]) # spent 3.72ms making 1 call to File::Spec::Unix::rel2abs
# spent 30µs making 1 call to File::Spec::Unix::splitpath | ||
21 | 1 | 2µs | } # spent 2µs making 1 call to Encode::utf8::encode_xs | ||
22 | |||||
23 | 1 | 67µs | 2 | 30µs | sub _const { # spent 26µs making 1 call to Encode::utf8::decode_xs
# spent 3µs making 1 call to Encode::Encoding::renewed |
24 | my $value = shift; | ||||
25 | sub () { $value } | ||||
26 | 1 | 2µs | } # spent 2µs making 1 call to Encode::utf8::encode_xs | ||
27 | |||||
28 | 1 | 46µs | 2 | 31µs | # spent 20µs within Dir::Self::import which was called:
# once (20µs+0s) by hailo::BEGIN@5 at line 5 of bin/hailo # spent 28µs making 1 call to Encode::utf8::decode_xs
# spent 4µs making 1 call to Encode::Encoding::renewed |
29 | 6 | 22µs | my $class = shift; | ||
30 | 1 | 2µs | my $caller = caller; # spent 2µs making 1 call to Encode::utf8::encode_xs | ||
31 | |||||
32 | 1 | 43µs | 3 | 32µs | @_ or @_ = '__DIR__'; # spent 26µs making 1 call to Encode::utf8::decode_xs
# spent 3µs making 1 call to Encode::Encoding::renewed
# spent 2µs making 1 call to Encode::utf8::encode_xs |
33 | |||||
34 | 1 | 47µs | 2 | 30µs | for my $item (@_) { # spent 26µs making 1 call to Encode::utf8::decode_xs
# spent 3µs making 1 call to Encode::Encoding::renewed |
35 | if ($item eq '__DIR__') { | ||||
36 | 2 | 44µs | 2 | 64µs | # spent 38µs (12+26) within Dir::Self::BEGIN@36 which was called:
# once (12µs+26µs) by hailo::BEGIN@5 at line 36 # spent 38µs making 1 call to Dir::Self::BEGIN@36
# spent 26µs making 1 call to strict::unimport |
37 | *{$caller . '::__DIR__'} = \&__DIR__; | ||||
38 | } elsif ($item eq ':static') { | ||||
39 | 2 | 74µs | 2 | 55µs | # spent 33µs (11+22) within Dir::Self::BEGIN@39 which was called:
# once (11µs+22µs) by hailo::BEGIN@5 at line 39 # spent 33µs making 1 call to Dir::Self::BEGIN@39
# spent 22µs making 1 call to strict::unimport |
40 | *{$caller . '::__DIR__'} = _const &__DIR__(1); | ||||
41 | } else { | ||||
42 | _croak qq{"$item" is not exported by the $class module}; | ||||
43 | } | ||||
44 | } | ||||
45 | 1 | 2µs | } # spent 2µs making 1 call to Encode::utf8::encode_xs | ||
46 | |||||
47 | 1 | 42µs | 2 | 30µs | 1 # spent 27µs making 1 call to Encode::utf8::decode_xs
# spent 3µs making 1 call to Encode::Encoding::renewed |
48 | __END__ | ||||
49 | |||||
50 | =head1 NAME | ||||
51 | |||||
52 | Dir::Self - a __DIR__ constant for the directory your source file is in | ||||
53 | |||||
54 | =head1 SYNOPSIS | ||||
55 | |||||
56 | use Dir::Self; | ||||
57 | |||||
58 | use lib __DIR__ . "/lib"; | ||||
59 | |||||
60 | my $conffile = __DIR__ . "/config"; | ||||
61 | |||||
62 | =head1 DESCRIPTION | ||||
63 | |||||
64 | Perl has two pseudo-constants describing the current location in your source | ||||
65 | code, C<__FILE__> and C<__LINE__>. This module adds C<__DIR__>, which expands | ||||
66 | to the directory your source file is in, as an absolute pathname. | ||||
67 | |||||
68 | This is useful if your code wants to access files in the same directory, like | ||||
69 | helper modules or configuration data. This is a bit like L<FindBin> except | ||||
70 | it's not limited to the main program, i.e. you can also use it in modules. And | ||||
71 | it actually works. | ||||
72 | |||||
73 | As of version 0.10 each use of C<__DIR__> recomputes the directory name; this | ||||
74 | ensures that files in different directories that share the same package name | ||||
75 | get correct results. If you don't want this, C<use Dir::Self qw(:static)> will | ||||
76 | create a true C<__DIR__> constant in your package that contains the directory | ||||
77 | name at the point of C<use>. | ||||
78 | |||||
79 | =head1 AUTHOR | ||||
80 | |||||
81 | Lukas Mai E<lt>l.mai @web.deE<gt> | ||||
82 | |||||
83 | =head1 COPYRIGHT AND LICENSE | ||||
84 | |||||
85 | Copyright (C) 2007, 2008 by Lukas Mai | ||||
86 | |||||
87 | This library is free software; you can redistribute it and/or modify | ||||
88 | it under the same terms as Perl itself, either Perl version 5.8.8 or, | ||||
89 | at your option, any later version of Perl 5 you may have available. | ||||
90 | |||||
91 | =cut |