← 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 11:58:52 2013
Reported on Tue Oct 15 12:01:30 2013

Filename/usr/share/perl/5.10/autouse.pm
StatementsExecuted 22 statements in 629µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11144µs136µsautouse::::importautouse::import
11131µs31µsautouse::::BEGIN@4autouse::BEGIN@4
11124µs28µsautouse::::vet_importautouse::vet_import
11117µs41µsautouse::::BEGIN@56autouse::BEGIN@56
2218µs8µ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
43335µs131µs
# spent 31µs within autouse::BEGIN@4 which was called: # once (31µs+0s) by C4::Koha::BEGIN@31 at line 4
use 5.006; # use warnings
# spent 31µs making 1 call to autouse::BEGIN@4
5
61600ns$autouse::VERSION = '1.06';
7
81600ns$autouse::DEBUG ||= 0;
9
10sub vet_import ($);
11
12sub croak {
13 require Carp;
14 Carp::croak(@_);
15}
16
17
# spent 136µs (44+92) within autouse::import which was called: # once (44µs+92µs) by C4::Koha::BEGIN@31 at line 31 of /usr/share/koha/lib/C4/Koha.pm
sub import {
18626µs my $class = @_ ? shift : 'autouse';
19 croak "usage: use $class MODULE [,SUBS...]" unless @_;
20 my $module = shift;
21
2216µs (my $pm = $module) =~ s{::}{/}g;
# spent 6µs making 1 call to autouse::CORE:subst
23 $pm .= '.pm';
24316µs if (exists $INC{$pm}) {
25128µs vet_import $module;
# spent 28µs making 1 call to autouse::vet_import
26 local $Exporter::ExportLevel = $Exporter::ExportLevel + 1;
27 # $Exporter::Verbose = 1;
2829µs257µs return $module->import(map { (my $f = $_) =~ s/\(.*?\)$//; $f } @_);
# spent 56µs making 1 call to Exporter::import # spent 2µs 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 }
563209µs264µs
# spent 41µs (17+24) within autouse::BEGIN@56 which was called: # once (17µs+24µs) by C4::Koha::BEGIN@31 at line 56
no warnings qw(redefine prototype);
# spent 41µs making 1 call to autouse::BEGIN@56 # spent 24µ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 28µs (24+4) within autouse::vet_import which was called: # once (24µs+4µs) by autouse::import at line 25
sub vet_import ($) {
74229µs my $module = shift;
7514µs if (my $import = $module->can('import')) {
# spent 4µ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
8314µs1;
84
85__END__
 
# spent 8µs within autouse::CORE:subst which was called 2 times, avg 4µs/call: # once (6µs+0s) by autouse::import at line 22 # once (2µs+0s) by autouse::import at line 28
sub autouse::CORE:subst; # opcode