← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/share/koha/opac/cgi-bin/opac/opac-search.pl
  Run on Tue Oct 15 17:10:45 2013
Reported on Tue Oct 15 17:11:56 2013

Filename/usr/share/perl/5.10/autouse.pm
StatementsExecuted 22 statements in 747µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11153µs53µsautouse::::BEGIN@4autouse::BEGIN@4
11132µs131µsautouse::::importautouse::import
11119µs46µsautouse::::BEGIN@56autouse::BEGIN@56
11117µs20µsautouse::::vet_importautouse::vet_import
22111µs11µsautouse::::CORE:substautouse::CORE:subst (opcode)
0000s0sautouse::::__ANON__[:62]autouse::__ANON__[:62]
0000s0sautouse::::croakautouse::croak
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package autouse;
2
3#use strict; # debugging only
43465µs153µs
# spent 53µs within autouse::BEGIN@4 which was called: # once (53µs+0s) by C4::Koha::BEGIN@31 at line 4
use 5.006; # use warnings
# spent 53µs making 1 call to autouse::BEGIN@4
5
61800ns$autouse::VERSION = '1.06';
7
81400ns$autouse::DEBUG ||= 0;
9
10sub vet_import ($);
11
12sub croak {
13 require Carp;
14 Carp::croak(@_);
15}
16
17
# spent 131µs (32+99) within autouse::import which was called: # once (32µs+99µs) by C4::Koha::BEGIN@31 at line 31 of /usr/share/koha/lib/C4/Koha.pm
sub import {
18623µs my $class = @_ ? shift : 'autouse';
19 croak "usage: use $class MODULE [,SUBS...]" unless @_;
20 my $module = shift;
21
22110µs (my $pm = $module) =~ s{::}{/}g;
# spent 10µs making 1 call to autouse::CORE:subst
23 $pm .= '.pm';
24311µs if (exists $INC{$pm}) {
25120µs vet_import $module;
# spent 20µs making 1 call to autouse::vet_import
26 local $Exporter::ExportLevel = $Exporter::ExportLevel + 1;
27 # $Exporter::Verbose = 1;
2825µs269µs return $module->import(map { (my $f = $_) =~ s/\(.*?\)$//; $f } @_);
# spent 69µs making 1 call to Exporter::import # spent 600ns making 1 call to autouse::CORE:subst
29 }
30
31 # It is not loaded: need to do real work.
32 my $callpkg = caller(0);
33 print "autouse called from $callpkg\n" if $autouse::DEBUG;
34
35 my $index;
36 for my $f (@_) {
37 my $proto;
38 $proto = $1 if (my $func = $f) =~ s/\((.*)\)$//;
39
40 my $closure_import_func = $func; # Full name
41 my $closure_func = $func; # Name inside package
42 my $index = rindex($func, '::');
43 if ($index == -1) {
44 $closure_import_func = "${callpkg}::$func";
45 } else {
46 $closure_func = substr $func, $index + 2;
47 croak "autouse into different package attempted"
48 unless substr($func, 0, $index) eq $module;
49 }
50
51 my $load_sub = sub {
52 unless ($INC{$pm}) {
53 require $pm;
54 vet_import $module;
55 }
563217µs274µs
# spent 46µs (19+27) within autouse::BEGIN@56 which was called: # once (19µs+27µs) by C4::Koha::BEGIN@31 at line 56
no warnings qw(redefine prototype);
# spent 46µs making 1 call to autouse::BEGIN@56 # spent 27µs making 1 call to warnings::unimport
57 *$closure_import_func = \&{"${module}::$closure_func"};
58 print "autousing $module; "
59 ."imported $closure_func as $closure_import_func\n"
60 if $autouse::DEBUG;
61 goto &$closure_import_func;
62 };
63
64 if (defined $proto) {
65 *$closure_import_func = eval "sub ($proto) { goto &\$load_sub }"
66 || die;
67 } else {
68 *$closure_import_func = $load_sub;
69 }
70 }
71}
72
73
# spent 20µs (17+3) within autouse::vet_import which was called: # once (17µs+3µs) by autouse::import at line 25
sub vet_import ($) {
74222µs my $module = shift;
7513µs if (my $import = $module->can('import')) {
# spent 3µs making 1 call to UNIVERSAL::can
76 croak "autoused module $module has unique import() method"
77 unless defined(&Exporter::import)
78 && ($import == \&Exporter::import ||
79 $import == \&UNIVERSAL::import)
80 }
81}
82
8313µs1;
84
85__END__
 
# spent 11µs within autouse::CORE:subst which was called 2 times, avg 6µs/call: # once (10µs+0s) by autouse::import at line 22 # once (600ns+0s) by autouse::import at line 28
sub autouse::CORE:subst; # opcode