← Index
NYTProf Performance Profile   « line view »
For webmerge/scripts/webmerge.pl
  Run on Mon Oct 7 02:42:42 2013
Reported on Mon Oct 7 03:03:24 2013

Filename/usr/lib64/perl5/vendor_perl/5.16.0/IO/WrapTie.pm
StatementsExecuted 31 statements in 4.96ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.98ms1.98msIO::WrapTie::Master::::PRELOADIO::WrapTie::Master::PRELOAD
11184µs192µsIO::WrapTie::::BEGIN@8 IO::WrapTie::BEGIN@8
11156µs147µsIO::WrapTie::Master::::BEGIN@34IO::WrapTie::Master::BEGIN@34
11155µs161µsIO::WrapTie::::BEGIN@10 IO::WrapTie::BEGIN@10
11154µs154µsIO::WrapTie::Master::::BEGIN@36IO::WrapTie::Master::BEGIN@36
11150µs352µsIO::WrapTie::::BEGIN@9 IO::WrapTie::BEGIN@9
11149µs266µsIO::WrapTie::Master::::BEGIN@35IO::WrapTie::Master::BEGIN@35
0000s0sIO::WrapTie::Master::::AUTOLOADIO::WrapTie::Master::AUTOLOAD
0000s0sIO::WrapTie::Master::::newIO::WrapTie::Master::new
0000s0sIO::WrapTie::Slave::::TIE_MASTER IO::WrapTie::Slave::TIE_MASTER
0000s0sIO::WrapTie::Slave::::new_tie IO::WrapTie::Slave::new_tie
0000s0sIO::WrapTie::::new IO::WrapTie::new
0000s0sIO::WrapTie::::wraptie IO::WrapTie::wraptie
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# SEE DOCUMENTATION AT BOTTOM OF FILE
2
3
4#------------------------------------------------------------
5package IO::WrapTie;
6#------------------------------------------------------------
7162µsrequire 5.004; ### for tie
82174µs2299µs
# spent 192µs (84+108) within IO::WrapTie::BEGIN@8 which was called: # once (84µs+108µs) by RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@26 at line 8
use strict;
# spent 192µs making 1 call to IO::WrapTie::BEGIN@8 # spent 108µs making 1 call to strict::import
92150µs2654µs
# spent 352µs (50+302) within IO::WrapTie::BEGIN@9 which was called: # once (50µs+302µs) by RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@26 at line 9
use vars qw(@ISA @EXPORT $VERSION);
# spent 352µs making 1 call to IO::WrapTie::BEGIN@9 # spent 302µs making 1 call to vars::import
102684µs2267µs
# spent 161µs (55+106) within IO::WrapTie::BEGIN@10 which was called: # once (55µs+106µs) by RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@26 at line 10
use Exporter;
# spent 161µs making 1 call to IO::WrapTie::BEGIN@10 # spent 106µs making 1 call to Exporter::import
11
12# Inheritance, exporting, and package version:
13134µs@ISA = qw(Exporter);
1416µs@EXPORT = qw(wraptie);
1512µs$VERSION = "2.110";
16
17# Function, exported.
18sub wraptie {
19 IO::WrapTie::Master->new(@_);
20}
21
22# Class method; BACKWARDS-COMPATIBILITY ONLY!
23sub new {
24 shift;
25 IO::WrapTie::Master->new(@_);
26}
27
- -
30#------------------------------------------------------------
31package IO::WrapTie::Master;
32#------------------------------------------------------------
33
342156µs2237µs
# spent 147µs (56+90) within IO::WrapTie::Master::BEGIN@34 which was called: # once (56µs+90µs) by RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@26 at line 34
use strict;
# spent 147µs making 1 call to IO::WrapTie::Master::BEGIN@34 # spent 90µs making 1 call to strict::import
352160µs2482µs
# spent 266µs (49+217) within IO::WrapTie::Master::BEGIN@35 which was called: # once (49µs+217µs) by RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@26 at line 35
use vars qw(@ISA $AUTOLOAD);
# spent 266µs making 1 call to IO::WrapTie::Master::BEGIN@35 # spent 217µs making 1 call to vars::import
3621.45ms2254µs
# spent 154µs (54+100) within IO::WrapTie::Master::BEGIN@36 which was called: # once (54µs+100µs) by RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@26 at line 36
use IO::Handle;
# spent 154µs making 1 call to IO::WrapTie::Master::BEGIN@36 # spent 100µs making 1 call to Exporter::import
37
38# We inherit from IO::Handle to get methods which invoke i/o operators,
39# like print(), on our tied handle:
40126µs@ISA = qw(IO::Handle);
41
42#------------------------------
43# new SLAVE, TIEARGS...
44#------------------------------
45# Create a new subclass of IO::Handle which...
46#
47# (1) Handles i/o OPERATORS because it is tied to an instance of
48# an i/o-like class, like IO::Scalar.
49#
50# (2) Handles i/o METHODS by delegating them to that same tied object!.
51#
52# Arguments are the slave class (e.g., IO::Scalar), followed by all
53# the arguments normally sent into that class's TIEHANDLE method.
54# In other words, much like the arguments to tie(). :-)
55#
56# NOTE:
57# The thing $x we return must be a BLESSED REF, for ($x->print()).
58# The underlying symbol must be a FILEHANDLE, for (print $x "foo").
59# It has to have a way of getting to the "real" back-end object...
60#
61sub new {
62 my $master = shift;
63 my $io = IO::Handle->new; ### create a new handle
64 my $slave = shift;
65 tie *$io, $slave, @_; ### tie: will invoke slave's TIEHANDLE
66 bless $io, $master; ### return a master
67}
68
69#------------------------------
70# AUTOLOAD
71#------------------------------
72# Delegate method invocations on the master to the underlying slave.
73#
74sub AUTOLOAD {
75 my $method = $AUTOLOAD;
76 $method =~ s/.*:://;
77 my $self = shift; tied(*$self)->$method(\@_);
78}
79
80#------------------------------
81# PRELOAD
82#------------------------------
83# Utility.
84#
85# Most methods like print(), getline(), etc. which work on the tied object
86# via Perl's i/o operators (like 'print') are inherited from IO::Handle.
87#
88# Other methods, like seek() and sref(), we must delegate ourselves.
89# AUTOLOAD takes care of these.
90#
91# However, it may be necessary to preload delegators into your
92# own class. PRELOAD will do this.
93#
94
# spent 1.98ms within IO::WrapTie::Master::PRELOAD which was called: # once (1.98ms+0s) by RTP::Webmerge::Process::CSS::Inlinedata::BEGIN@26 at line 105
sub PRELOAD {
9514µs my $class = shift;
96143µs foreach (@_) {
97101.96ms eval "sub ${class}::$_ { my \$s = shift; tied(*\$s)->$_(\@_) }";
# spent 0s executing statements in string eval
98 }
99}
100
101# Preload delegators for some standard methods which we can't simply
102# inherit from IO::Handle... for example, some IO::Handle methods
103# assume that there is an underlying file descriptor.
104#
105126µs11.98msPRELOAD IO::WrapTie::Master
# spent 1.98ms making 1 call to IO::WrapTie::Master::PRELOAD
106 qw(open opened close read clearerr eof seek tell setpos getpos);
107
- -
110#------------------------------------------------------------
111package IO::WrapTie::Slave;
112#------------------------------------------------------------
113# Teeny private class providing a new_tie constructor...
114#
115# HOW IT ALL WORKS:
116#
117# Slaves inherit from this class.
118#
119# When you send a new_tie() message to a tie-slave class (like IO::Scalar),
120# it first determines what class should provide its master, via TIE_MASTER.
121# In this case, IO::Scalar->TIE_MASTER would return IO::Scalar::Master.
122# Then, we create a new master (an IO::Scalar::Master) with the same args
123# sent to new_tie.
124#
125# In general, the new() method of the master is inherited directly
126# from IO::WrapTie::Master.
127#
128sub new_tie {
129 my $self = shift;
130 $self->TIE_MASTER->new($self,@_); ### e.g., IO::Scalar::Master->new(@_)
131}
132
133# Default class method for new_tie().
134# All your tie-slave class (like IO::Scalar) has to do is override this
135# method with a method that returns the name of an appropriate "master"
136# class for tying that slave.
137#
138sub TIE_MASTER { 'IO::WrapTie::Master' }
139
140#------------------------------
141131µs1;
142__END__