← Index
NYTProf Performance Profile   « block view • line view • sub view »
For mongo_pain.pl
  Run on Fri Mar 25 17:00:29 2011
Reported on Fri Mar 25 17:07:07 2011

Filename/usr/share/perl/5.10/Exporter.pm
StatementsExecuted 341 statements in 1.11ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
191915982µs1.03msExporter::::importExporter::import
441131µs31µsExporter::::CORE:matchExporter::CORE:match (opcode)
451116µs16µsExporter::::CORE:substExporter::CORE:subst (opcode)
0000s0sExporter::::__ANON__[:65]Exporter::__ANON__[:65]
0000s0sExporter::::as_heavyExporter::as_heavy
0000s0sExporter::::exportExporter::export
0000s0sExporter::::export_failExporter::export_fail
0000s0sExporter::::export_ok_tagsExporter::export_ok_tags
0000s0sExporter::::export_tagsExporter::export_tags
0000s0sExporter::::export_to_levelExporter::export_to_level
0000s0sExporter::::require_versionExporter::require_version
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Exporter;
2
3117µsrequire 5.006;
4
5# Be lean.
6#use strict;
7#no strict 'refs';
8
91500nsour $Debug = 0;
101200nsour $ExportLevel = 0;
111400nsour $Verbose ||= 0;
121400nsour $VERSION = '5.63';
131300nsour (%Cache);
14
15# Carp 1.05+ does this now for us, but we may be running with an old Carp
1612µs$Carp::Internal{Exporter}++;
17
18sub as_heavy {
19 require Exporter::Heavy;
20 # Unfortunately, this does not work if the caller is aliased as *name = \&foo
21 # Thus the need to create a lot of identical subroutines
22 my $c = (caller(1))[3];
23 $c =~ s/.*:://;
24 \&{"Exporter::Heavy::heavy_$c"};
25}
26
27sub export {
28 goto &{as_heavy()};
29}
30
31
# spent 1.03ms (982µs+48µs) within Exporter::import which was called 19 times, avg 54µs/call: # once (95µs+7µs) by DateTime::Duration::BEGIN@12 at line 12 of DateTime/Duration.pm # once (69µs+6µs) by Class::Load::BEGIN@6 at line 6 of Class/Load.pm # once (68µs+3µs) by DateTime::TimeZone::BEGIN@16 at line 16 of DateTime/TimeZone.pm # once (67µs+3µs) by DateTime::BEGIN@49 at line 49 of DateTime.pm # once (62µs+4µs) by DateTime::TimeZone::Local::BEGIN@9 at line 9 of DateTime/TimeZone/Local.pm # once (62µs+2µs) by MongoDB::Cursor::BEGIN@22 at line 22 of MongoDB/Cursor.pm # once (56µs+2µs) by DateTime::TimeZone::OffsetOnly::BEGIN@13 at line 13 of DateTime/TimeZone/OffsetOnly.pm # once (55µs+3µs) by DateTime::Locale::BEGIN@12 at line 12 of DateTime/Locale.pm # once (52µs+4µs) by DateTime::Locale::Base::BEGIN@6 at line 6 of DateTime/Locale/Base.pm # once (50µs+2µs) by MongoDB::Collection::BEGIN@49 at line 49 of MongoDB/Collection.pm # once (49µs+2µs) by Time::Local::BEGIN@4 at line 4 of Time/Local.pm # once (48µs+2µs) by Tie::Hash::BEGIN@5 at line 5 of Tie/Hash.pm # once (47µs+3µs) by DateTime::BEGIN@47 at line 47 of DateTime.pm # once (44µs+2µs) by DateTime::BEGIN@11 at line 11 of DateTime.pm # once (41µs+2µs) by MongoDB::Connection::BEGIN@29 at line 29 of MongoDB/Connection.pm # once (37µs+1µs) by DateTime::Locale::Base::BEGIN@9 at line 9 of DateTime/Locale/Base.pm # once (28µs+0s) by MongoDB::GridFS::BEGIN@25 at line 25 of MongoDB/GridFS.pm # once (27µs+0s) by Params::Validate::BEGIN@6 at line 6 of Params/Validate.pm # once (26µs+0s) by MongoDB::Connection::BEGIN@27 at line 27 of MongoDB/Connection.pm
sub import {
32285738µs my $pkg = shift;
33 my $callpkg = caller($ExportLevel);
34
35 if ($pkg eq "Exporter" and @_ and $_[0] eq "import") {
36 *{$callpkg."::import"} = \&import;
37 return;
38 }
39
40 # We *need* to treat @{"$pkg\::EXPORT_FAIL"} since Carp uses it :-(
41 my($exports, $fail) = (\@{"$pkg\::EXPORT"}, \@{"$pkg\::EXPORT_FAIL"});
42 return export $pkg, $callpkg, @_
43 if $Verbose or $Debug or @$fail > 1;
44 my $export_cache = ($Cache{$pkg} ||= {});
45 my $args = @_ or @_ = @$exports;
46
47 local $_;
4810151µs if ($args and not %$export_cache) {
49 s/^&//, $export_cache->{$_} = 1
504516µs foreach (@$exports, @{"$pkg\::EXPORT_OK"});
# spent 16µs making 45 calls to Exporter::CORE:subst, avg 367ns/call
51 }
52 my $heavy;
53 # Try very hard not to use {} and hence have to enter scope on the foreach
54 # We bomb out of the loop with last as soon as heavy is set.
5538198µs if ($args or $fail) {
56 ($heavy = (/\W/ or $args and not exists $export_cache->{$_}
57 or @$fail and $_ eq $fail->[0])) and last
584431µs foreach (@_);
# spent 31µs making 44 calls to Exporter::CORE:match, avg 711ns/call
59 } else {
60 ($heavy = /\W/) and last
61 foreach (@_);
62 }
63 return export $pkg, $callpkg, ($args ? @_ : ()) if $heavy;
64 local $SIG{__WARN__} =
65 sub {require Carp; &Carp::carp};
66 # shortcut for the common case of no type character
67 *{"$callpkg\::$_"} = \&{"$pkg\::$_"} foreach @_;
68}
69
70# Default methods
71
72sub export_fail {
73 my $self = shift;
74 @_;
75}
76
77# Unfortunately, caller(1)[3] "does not work" if the caller is aliased as
78# *name = \&foo. Thus the need to create a lot of identical subroutines
79# Otherwise we could have aliased them to export().
80
81sub export_to_level {
82 goto &{as_heavy()};
83}
84
85sub export_tags {
86 goto &{as_heavy()};
87}
88
89sub export_ok_tags {
90 goto &{as_heavy()};
91}
92
93sub require_version {
94 goto &{as_heavy()};
95}
96
9716µs1;
98__END__
 
# spent 31µs within Exporter::CORE:match which was called 44 times, avg 711ns/call: # 44 times (31µs+0s) by Exporter::import at line 58, avg 711ns/call
sub Exporter::CORE:match; # opcode
# spent 16µs within Exporter::CORE:subst which was called 45 times, avg 367ns/call: # 45 times (16µs+0s) by Exporter::import at line 50, avg 367ns/call
sub Exporter::CORE:subst; # opcode