Profile of lib.pm

← Index
NYTProf Performance Profile «line view»
For examples/benchmark4.pl
Run on Thu Aug 28 19:01:43 2014
Reported on Thu Aug 28 19:02:42 2014

Filename | /usr/lib/perl/5.18/lib.pm
Statements | Executed 33 statements in 509µs

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
1 | 1 | 1 | 37µs | 53µs | lib::::importlib::import
1 | 1 | 1 | 14µs | 23µs | lib::::BEGIN@6lib::BEGIN@6
1 | 1 | 1 | 6µs | 18µs | lib::::BEGIN@8lib::BEGIN@8
5 | 5 | 1 | 6µs | 6µs | lib::::CORE:ftdirlib::CORE:ftdir (opcode)
1 | 1 | 1 | 5µs | 5µs | lib::::_get_dirslib::_get_dirs
1 | 1 | 1 | 4µs | 4µs | lib::::CORE:ftislib::CORE:ftis (opcode)
1 | 1 | 1 | 2µs | 2µs | lib::::CORE:matchlib::CORE:match (opcode)
0 | 0 | 0 | 0s | 0s | lib::::unimportlib::unimport

Call graph for these subroutines as a Graphviz dot language file.

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package lib;
2 |  |  |  |  |
3 |  |  |  |  | # THIS FILE IS AUTOMATICALLY GENERATED FROM lib_pm.PL.
4 |  |  |  |  | # ANY CHANGES TO THIS FILE WILL BE OVERWRITTEN BY THE NEXT PERL BUILD.
5 |  |  |  |  |
6 | 2 | 26µs | 2 | 32µs | # spent 23µs (14+9) within lib::BEGIN@6 which was called: # once (14µs+9µs) by main::BEGIN@4 at line 6 use Config; # spent 23µs making 1 call to lib::BEGIN@6 # spent 9µs making 1 call to Config::import
7 |  |  |  |  |
8 | 2 | 409µs | 2 | 30µs | # spent 18µs (6+12) within lib::BEGIN@8 which was called: # once (6µs+12µs) by main::BEGIN@4 at line 8 use strict; # spent 18µs making 1 call to lib::BEGIN@8 # spent 12µs making 1 call to strict::import
9 |  |  |  |  |
10 | 1 | 6µs | 1 | 4µs | my $archname = $Config{archname}; # spent 4µs making 1 call to Config::FETCH
11 | 1 | 3µs | 1 | 2µs | my $version = $Config{version}; # spent 2µs making 1 call to Config::FETCH
12 | 1 | 4µs | 1 | 2µs | my @inc_version_list = reverse split / /, $Config{inc_version_list}; # spent 2µs making 1 call to Config::FETCH
13 |  |  |  |  |
14 | 1 | 2µs |  |  | our @ORIG_INC = @INC; # take a handy copy of 'original' value
15 | 1 | 200ns |  |  | our $VERSION = '0.63';
16 |  |  |  |  |
17 |  |  |  |  | # spent 53µs (37+17) within lib::import which was called: # once (37µs+17µs) by main::BEGIN@4 at line 4 of examples/benchmark4.pl sub import {
18 | 1 | 200ns |  |  | shift;
19 |  |  |  |  |
20 | 1 | 100ns |  |  | my %names;
21 | 1 | 800ns |  |  | foreach (reverse @_) {
22 | 1 | 300ns |  |  | my $path = $_; # we'll be modifying it, so break the alias
23 | 1 | 300ns |  |  | if ($path eq '') {
24 |  |  |  |  | require Carp;
25 |  |  |  |  | Carp::carp("Empty compile time value given to use lib");
26 |  |  |  |  | }
27 |  |  |  |  |
28 | 1 | 16µs | 3 | 6µs | if ($path !~ /\.par$/i && -e $path && ! -d _) { # spent 4µs making 1 call to lib::CORE:ftis # spent 2µs making 1 call to lib::CORE:match # spent 300ns making 1 call to lib::CORE:ftdir
29 |  |  |  |  | require Carp;
30 |  |  |  |  | Carp::carp("Parameter to use lib must be directory, not file");
31 |  |  |  |  | }
32 | 1 | 1µs |  |  | unshift(@INC, $path);
33 |  |  |  |  | # Add any previous version directories we found at configure time
34 | 1 | 800ns |  |  | foreach my $incver (@inc_version_list)
35 |  |  |  |  | {
36 | 1 | 700ns |  |  | my $dir = "$path/$incver";
37 | 1 | 5µs | 1 | 2µs | unshift(@INC, $dir) if -d $dir; # spent 2µs making 1 call to lib::CORE:ftdir
38 |  |  |  |  | }
39 |  |  |  |  | # Put a corresponding archlib directory in front of $path if it
40 |  |  |  |  | # looks like $path has an archlib directory below it.
41 | 1 | 2µs | 1 | 5µs | my($arch_auto_dir, $arch_dir, $version_dir, $version_arch_dir) # spent 5µs making 1 call to lib::_get_dirs
42 |  |  |  |  | = _get_dirs($path);
43 | 1 | 4µs | 1 | 2µs | unshift(@INC, $arch_dir) if -d $arch_auto_dir; # spent 2µs making 1 call to lib::CORE:ftdir
44 | 1 | 3µs | 1 | 1µs | unshift(@INC, $version_dir) if -d $version_dir; # spent 1µs making 1 call to lib::CORE:ftdir
45 | 1 | 3µs | 1 | 1µs | unshift(@INC, $version_arch_dir) if -d $version_arch_dir; # spent 1µs making 1 call to lib::CORE:ftdir
46 |  |  |  |  | }
47 |  |  |  |  |
48 |  |  |  |  | # remove trailing duplicates
49 | 1 | 9µs |  |  | @INC = grep { ++$names{$_} == 1 } @INC;
50 | 1 | 4µs |  |  | return;
51 |  |  |  |  | }
52 |  |  |  |  |
53 |  |  |  |  | sub unimport {
54 |  |  |  |  | shift;
55 |  |  |  |  |
56 |  |  |  |  | my %names;
57 |  |  |  |  | foreach my $path (@_) {
58 |  |  |  |  | my($arch_auto_dir, $arch_dir, $version_dir, $version_arch_dir)
59 |  |  |  |  | = _get_dirs($path);
60 |  |  |  |  | ++$names{$path};
61 |  |  |  |  | ++$names{$arch_dir} if -d $arch_auto_dir;
62 |  |  |  |  | ++$names{$version_dir} if -d $version_dir;
63 |  |  |  |  | ++$names{$version_arch_dir} if -d $version_arch_dir;
64 |  |  |  |  | }
65 |  |  |  |  |
66 |  |  |  |  | # Remove ALL instances of each named directory.
67 |  |  |  |  | @INC = grep { !exists $names{$_} } @INC;
68 |  |  |  |  | return;
69 |  |  |  |  | }
70 |  |  |  |  |
71 |  |  |  |  | # spent 5µs within lib::_get_dirs which was called: # once (5µs+0s) by lib::import at line 41 sub _get_dirs {
72 | 1 | 500ns |  |  | my($dir) = @_;
73 | 1 | 200ns |  |  | my($arch_auto_dir, $arch_dir, $version_dir, $version_arch_dir);
74 |  |  |  |  |
75 | 1 | 1µs |  |  | $arch_auto_dir = "$dir/$archname/auto";
76 | 1 | 600ns |  |  | $arch_dir = "$dir/$archname";
77 | 1 | 400ns |  |  | $version_dir = "$dir/$version";
78 | 1 | 500ns |  |  | $version_arch_dir = "$dir/$version/$archname";
79 |  |  |  |  |
80 | 1 | 3µs |  |  | return($arch_auto_dir, $arch_dir, $version_dir, $version_arch_dir);
81 |  |  |  |  | }
82 |  |  |  |  |
83 | 1 | 6µs |  |  | 1;
84 |  |  |  |  | __END__
|  |  |  |  | # spent 6µs within lib::CORE:ftdir which was called 5 times, avg 1µs/call: # once (2µs+0s) by lib::import at line 37 # once (2µs+0s) by lib::import at line 43 # once (1µs+0s) by lib::import at line 44 # once (1µs+0s) by lib::import at line 45 # once (300ns+0s) by lib::import at line 28 sub lib::CORE:ftdir; # opcode
|  |  |  |  | # spent 4µs within lib::CORE:ftis which was called: # once (4µs+0s) by lib::import at line 28 sub lib::CORE:ftis; # opcode
|  |  |  |  | # spent 2µs within lib::CORE:match which was called: # once (2µs+0s) by lib::import at line 28 sub lib::CORE:match; # opcode