📄 dbi::profile.3
字号:
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05).\".\" Standard preamble:.\" ========================================================================.de Sh \" Subsection heading.br.if t .Sp.ne 5.PP\fB\\$1\fR.PP...de Sp \" Vertical space (when we can't use .PP).if t .sp .5v.if n .sp...de Vb \" Begin verbatim text.ft CW.nf.ne \\$1...de Ve \" End verbatim text.ft R.fi...\" Set up some character translations and predefined strings. \*(-- will.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left.\" double quote, and \*(R" will give a right double quote. \*(C+ will.\" give a nicer C++. Capital omega is used to do unbreakable dashes and.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,.\" nothing in troff, for use with C<>..tr \(*W-.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'.ie n \{\. ds -- \(*W-. ds PI pi. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch. ds L" "". ds R" "". ds C` "". ds C' ""'br\}.el\{\. ds -- \|\(em\|. ds PI \(*p. ds L" ``. ds R" '''br\}.\".\" Escape single quotes in literal strings from groff's Unicode transform..ie \n(.g .ds Aq \(aq.el .ds Aq '.\".\" If the F register is turned on, we'll generate index entries on stderr for.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index.\" entries marked with X<> in POD. Of course, you'll have to process the.\" output yourself in some meaningful fashion..ie \nF \{\. de IX. tm Index:\\$1\t\\n%\t"\\$2"... nr % 0. rr F.\}.el \{\. de IX...\}.\".\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2)..\" Fear. Run. Save yourself. No user-serviceable parts.. \" fudge factors for nroff and troff.if n \{\. ds #H 0. ds #V .8m. ds #F .3m. ds #[ \f1. ds #] \fP.\}.if t \{\. ds #H ((1u-(\\\\n(.fu%2u))*.13m). ds #V .6m. ds #F 0. ds #[ \&. ds #] \&.\}. \" simple accents for nroff and troff.if n \{\. ds ' \&. ds ` \&. ds ^ \&. ds , \&. ds ~ ~. ds /.\}.if t \{\. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u". ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'.\}. \" troff and (daisy-wheel) nroff accents.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'.ds 8 \h'\*(#H'\(*b\h'-\*(#H'.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#].ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#].ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#].ds ae a\h'-(\w'a'u*4/10)'e.ds Ae A\h'-(\w'A'u*4/10)'E. \" corrections for vroff.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'. \" for low resolution devices (crt and lpr).if \n(.H>23 .if \n(.V>19 \\{\. ds : e. ds 8 ss. ds o a. ds d- d\h'-1'\(ga. ds D- D\h'-1'\(hy. ds th \o'bp'. ds Th \o'LP'. ds ae ae. ds Ae AE.\}.rm #[ #] #H #V #F C.\" ========================================================================.\".IX Title "DBI::Profile 3".TH DBI::Profile 3 "2007-08-09" "perl v5.10.0" "User Contributed Perl Documentation".\" For nroff, turn off justification. Always turn off hyphenation; it makes.\" way too many mistakes in technical documents..if n .ad l.nh.SH "NAME"DBI::Profile \- Performance profiling and benchmarking for the DBI.SH "SYNOPSIS".IX Header "SYNOPSIS"The easiest way to enable \s-1DBI\s0 profiling is to set the \s-1DBI_PROFILE\s0environment variable to 2 and then run your code as usual:.PP.Vb 1\& DBI_PROFILE=2 prog.pl.Ve.PPThis will profile your program and then output a textual summarygrouped by query when the program exits. You can also enable profiling bysetting the Profile attribute of any \s-1DBI\s0 handle:.PP.Vb 1\& $dbh\->{Profile} = 2;.Ve.PPThen the summary will be printed when the handle is destroyed..PPMany other values apart from are possible \- see \*(L"\s-1ENABLING\s0 A \s-1PROFILE\s0\*(R" below..SH "DESCRIPTION".IX Header "DESCRIPTION"The DBI::Profile module provides a simple interface to collect andreport performance and benchmarking data from the \s-1DBI\s0..PPFor a more elaborate interface, suitable for larger programs, seeDBI::ProfileDumper and dbiprof.For Apache/mod_perl applications seeDBI::ProfileDumper::Apache..SH "OVERVIEW".IX Header "OVERVIEW"Performance data collection for the \s-1DBI\s0 is built around severalconcepts which are important to understand clearly..IP "Method Dispatch" 4.IX Item "Method Dispatch"Every method call on a \s-1DBI\s0 handle passes through a single 'dispatch'function which manages all the common aspects of \s-1DBI\s0 method calls,such as handling the RaiseError attribute..IP "Data Collection" 4.IX Item "Data Collection"If profiling is enabled for a handle then the dispatch code takesa high-resolution timestamp soon after it is entered. Then, aftercalling the appropriate method and just before returning, it takesanother high-resolution timestamp and calls a function to recordthe information. That function is passed the two timestampsplus the \s-1DBI\s0 handle and the name of the method that was called.That data about a single \s-1DBI\s0 method call is called a \fIprofile sample\fR..IP "Data Filtering" 4.IX Item "Data Filtering"If the method call was invoked by the \s-1DBI\s0 or by a driver then the call isignored for profiling because the time spent will be accounted for by theoriginal 'outermost' call for your code..SpFor example, the calls that the \fIselectrow_arrayref()\fR method makesto \fIprepare()\fR and \fIexecute()\fR etc. are not counted individuallybecause the time spent in those methods is going to be allocatedto the \fIselectrow_arrayref()\fR method when it returns. If this was notdone then it would be very easy to double count time spent insidethe \s-1DBI\s0..IP "Data Storage Tree" 4.IX Item "Data Storage Tree"The profile data is accumulated as 'leaves on a tree'. The 'path' through thebranches of the tree to a particular leaf is determined dynamically for each sample.This is a key feature of \s-1DBI\s0 profiliing..SpFor each profiled method call the \s-1DBI\s0 walks along the Path and uses each valuein the Path to step into and grow the Data tree..SpFor example, if the Path is.Sp.Vb 1\& [ \*(Aqfoo\*(Aq, \*(Aqbar\*(Aq, \*(Aqbaz\*(Aq ].Ve.Spthen the new profile sample data will be \fImerged\fR into the tree at.Sp.Vb 1\& $h\->{Profile}\->{Data}\->{foo}\->{bar}\->{baz}.Ve.SpBut it's not very useful to merge all the call data into one leaf node (exceptto get an overall 'time spent inside the \s-1DBI\s0' total). It's more common to wantthe Path to include dynamic values such as the current statement text and/orthe name of the method called to show what the time spent inside the \s-1DBI\s0 was for..SpThe Path can contain some 'magic cookie' values that are automatically replacedby corresponding dynamic values when they're used. These magic cookies alwaysstart with a punctuation character..SpFor example a value of '\f(CW\*(C`!MethodName\*(C'\fR' in the Path causes the correspondingentry in the Data to be the name of the method that was called.For example, if the Path was:.Sp.Vb 1\& [ \*(Aqfoo\*(Aq, \*(Aq!MethodName\*(Aq, \*(Aqbar\*(Aq ].Ve.Spand the \fIselectall_arrayref()\fR method was called, then the profile sample datafor that call will be merged into the tree at:.Sp.Vb 1\& $h\->{Profile}\->{Data}\->{foo}\->{selectall_arrayref}\->{bar}.Ve.IP "Profile Data" 4.IX Item "Profile Data"Profile data is stored at the 'leaves' of the tree as referencesto an array of numeric values. For example:.Sp.Vb 9\& [\& 106, # 0: count of samples at this node\& 0.0312958955764771, # 1: total duration\& 0.000490069389343262, # 2: first duration\& 0.000176072120666504, # 3: shortest duration\& 0.00140702724456787, # 4: longest duration\& 1023115819.83019, # 5: time of first sample\& 1023115819.86576, # 6: time of last sample\& ].Ve.SpAfter the first sample, later samples always update elements 0, 1, and 6, andmay update 3 or 4 depending on the duration of the sampled call..SH "ENABLING A PROFILE".IX Header "ENABLING A PROFILE"Profiling is enabled for a handle by assigning to the Profileattribute. For example:.PP.Vb 1\& $h\->{Profile} = DBI::Profile\->new();.Ve.PPThe Profile attribute holds a blessed reference to a hash objectthat contains the profile data and attributes relating to it..PPThe class the Profile object is blessed into is expected toprovide at least a \s-1DESTROY\s0 method which will dump the profile datato the \s-1DBI\s0 trace file handle (\s-1STDERR\s0 by default)..PPAll these examples have the same effect as each other:.PP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -