⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbi::profiledata.3

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 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::ProfileData 3".TH DBI::ProfileData 3 "2007-09-27" "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::ProfileData \- manipulate DBI::ProfileDumper data dumps.SH "SYNOPSIS".IX Header "SYNOPSIS"The easiest way to use this module is through the dbiprof frontend(see dbiprof for details):.PP.Vb 1\&  dbiprof \-\-number 15 \-\-sort count.Ve.PPThis module can also be used to roll your own profile analysis:.PP.Vb 2\&  # load data from dbi.prof\&  $prof = DBI::ProfileData\->new(File => "dbi.prof");\&\&  # get a count of the records (unique paths) in the data set\&  $count = $prof\->count();\&\&  # sort by longest overall time\&  $prof\->sort(field => "longest");\&\&  # sort by longest overall time, least to greatest\&  $prof\->sort(field => "longest", reverse => 1);\&\&  # exclude records with key2 eq \*(Aqdisconnect\*(Aq\&  $prof\->exclude(key2 => \*(Aqdisconnect\*(Aq);\&\&  # exclude records with key1 matching /^UPDATE/i\&  $prof\->exclude(key1 => qr/^UPDATE/i);\&\&  # remove all records except those where key1 matches /^SELECT/i\&  $prof\->match(key1 => qr/^SELECT/i);\&\&  # produce a formatted report with the given number of items\&  $report = $prof\->report(number => 10); \&\&  # clone the profile data set\&  $clone = $prof\->clone();\&\&  # get access to hash of header values\&  $header = $prof\->header();\&\&  # get access to sorted array of nodes\&  $nodes = $prof\->nodes();\&\&  # format a single node in the same style as report()\&  $text = $prof\->format($nodes\->[0]);\&\&  # get access to Data hash in DBI::Profile format\&  $Data = $prof\->Data();.Ve.SH "DESCRIPTION".IX Header "DESCRIPTION"This module offers the ability to read, manipulate and formatDBI::ProfileDumper profile data..PPConceptually, a profile consists of a series of records, or nodes,each of each has a set of statistics and set of keys.  Each recordmust have a unique set of keys, but there is no requirement that everyrecord have the same number of keys..SH "METHODS".IX Header "METHODS"The following methods are supported by DBI::ProfileData objects..ie n .Sh "$prof = DBI::ProfileData\->new(File => ""dbi.prof"")".el .Sh "\f(CW$prof\fP = DBI::ProfileData\->new(File => ``dbi.prof'')".IX Subsection "$prof = DBI::ProfileData->new(File => dbi.prof)".ie n .Sh "$prof = DBI::ProfileData\->new(File => ""dbi.prof"", Filter => sub { ... })".el .Sh "\f(CW$prof\fP = DBI::ProfileData\->new(File => ``dbi.prof'', Filter => sub { ... })".IX Subsection "$prof = DBI::ProfileData->new(File => dbi.prof, Filter => sub { ... })".ie n .Sh "$prof = DBI::ProfileData\->new(Files => [ ""dbi.prof.1"", ""dbi.prof.2"" ])".el .Sh "\f(CW$prof\fP = DBI::ProfileData\->new(Files => [ ``dbi.prof.1'', ``dbi.prof.2'' ])".IX Subsection "$prof = DBI::ProfileData->new(Files => [ dbi.prof.1, dbi.prof.2 ])"Creates a a new DBI::ProfileData object.  Takes either a single filethrough the File option or a list of Files in an array ref.  Ifmultiple files are specified then the header data from the first fileis used..PP\fIFiles\fR.IX Subsection "Files".PPReference to an array of file names to read..PP\fIFile\fR.IX Subsection "File".PPName of file to read. Takes precedence over \f(CW\*(C`Files\*(C'\fR..PP\fIDeleteFiles\fR.IX Subsection "DeleteFiles".PPIf true, the files are deleted after being read..PPActually the files are renamed with a C.deleteme> suffix before being read,and then, after reading all the files, they're all deleted together..PPThe files are locked while being read which, combined with the rename, makes itsafe to 'consume' files that are still being generated by DBI::ProfileDumper..PP\fIFilter\fR.IX Subsection "Filter".PPThe \f(CW\*(C`Filter\*(C'\fR parameter can be used to supply a code reference that canmanipulate the profile data as it is being read. This is most useful forediting \s-1SQL\s0 statements so that slightly different statements in the raw datawill be merged and aggregated in the loaded data. For example:.PP.Vb 4\&  Filter => sub {\&      my ($path_ref, $data_ref) = @_;\&      s/foo = \*(Aq.*?\*(Aq/foo = \*(Aq...\*(Aq/ for @$path_ref;\&  }.Ve.PPHere's an example that performs some normalization on the \s-1SQL\s0. It converts allnumbers to \f(CW\*(C`N\*(C'\fR and all quoted strings to \f(CW\*(C`S\*(C'\fR.  It can also convert digits toN within names. Finally, it summarizes long \*(L"\s-1IN\s0 (...)\*(R" clauses..PPIt's aggressive and simplistic, but it's often sufficient, and serves as anexample that you can tailor to suit your own needs:.PP.Vb 12\&  Filter => sub {\&      my ($path_ref, $data_ref) = @_;\&      local $_ = $path_ref\->[0]; # whichever element contains the SQL Statement\&      s/\eb\ed+\eb/N/g;             # 42 \-> N\&      s/\eb0x[0\-9A\-Fa\-f]+\eb/N/g;  # 0xFE \-> N\&      s/\*(Aq.*?\*(Aq/\*(AqS\*(Aq/g;             # single quoted strings (doesn\*(Aqt handle escapes)\&      s/".*?"/"S"/g;             # double quoted strings (doesn\*(Aqt handle escapes)\&      # convert names like log_20001231 into log_NNNNNNNN, controlled by $opt{n}\&      s/([a\-z_]+)(\ed{$opt{n},})/$1.(\*(AqN\*(Aq x length($2))/ieg if $opt{n};\&      # abbreviate massive "in (...)" statements and similar\&      s!(([NS],){100,})!sprintf("$2,{repeated %d times}",length($1)/2)!eg;\&  }.Ve.PPIt's often better to perform this kinds of normalization in the \s-1DBI\s0 while thedata is being collected, to avoid too much memory being used by storing profiledata for many different \s-1SQL\s0 statement. See DBI::Profile..ie n .Sh "$copy\fP = \f(CW$prof\fP\->\fIclone();".el .Sh "\f(CW$copy\fP = \f(CW$prof\fP\->\fIclone()\fP;".IX Subsection "$copy = $prof->clone();"Clone a profile data set creating a new object..ie n .Sh "$header\fP = \f(CW$prof\fP\->\fIheader();".el .Sh "\f(CW$header\fP = \f(CW$prof\fP\->\fIheader()\fP;".IX Subsection "$header = $prof->header();"Returns a reference to a hash of header values.  These are the keyvalue pairs included in the header section of the DBI::ProfileDumperdata format.  For example:.PP.Vb 4\&  $header = {\&    Path    => [ \*(Aq!Statement\*(Aq, \*(Aq!MethodName\*(Aq ],\&    Program => \*(Aqt/42profile_data.t\*(Aq,\&  };.Ve.PPNote that modifying this hash will modify the header data storedinside the profile object..ie n .Sh "$nodes\fP = \f(CW$prof\fP\->\fInodes()".el .Sh "\f(CW$nodes\fP = \f(CW$prof\fP\->\fInodes()\fP".IX Subsection "$nodes = $prof->nodes()"Returns a reference the sorted nodes array.  Each element in the arrayis a single record in the data set.  The first seven elements are thesame as the elements provided by DBI::Profile.  After that each key isin a separate element.  For example:.PP.Vb 10\& $nodes = [\&            [\&              2,                      # 0, count\&              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 event\&              1023115819.86576,       # 6, time of last event\&              \*(AqSELECT foo FROM bar\*(Aq   # 7, key1\&              \*(Aqexecute\*(Aq               # 8, key2\&                                      # 6+N, keyN\&            ],\&                                      # ...\&          ];.Ve.PPNote that modifying this array will modify the node data stored insidethe profile object..ie n .Sh "$count\fP = \f(CW$prof\fP\->\fIcount()".el .Sh "\f(CW$count\fP = \f(CW$prof\fP\->\fIcount()\fP".IX Subsection "$count = $prof->count()"Returns the number of items in the profile data set..ie n .Sh "$prof\->sort(field => ""field"")".el .Sh "\f(CW$prof\fP\->sort(field => ``field'')".IX Subsection "$prof->sort(field => field)".ie n .Sh "$prof\->sort(field => ""field"", reverse => 1)".el .Sh "\f(CW$prof\fP\->sort(field => ``field'', reverse => 1)".IX Subsection "$prof->sort(field => field, reverse => 1)"Sorts data by the given field.  Available fields are:.PP.Vb 4\&  longest\&  total\&  count\&  shortest.Ve.PPThe default sort is greatest to smallest, which is the opposite of thenormal Perl meaning.  This, however, matches the expected behavior ofthe dbiprof frontend..ie n .Sh "$count\fP = \f(CW$prof\->exclude(key2 => ""disconnect"")".el .Sh "\f(CW$count\fP = \f(CW$prof\fP\->exclude(key2 => ``disconnect'')".IX Subsection "$count = $prof->exclude(key2 => disconnect)".ie n .Sh "$count\fP = \f(CW$prof\->exclude(key2 => ""disconnect"", case_sensitive => 1)".el .Sh "\f(CW$count\fP = \f(CW$prof\fP\->exclude(key2 => ``disconnect'', case_sensitive => 1)".IX Subsection "$count = $prof->exclude(key2 => disconnect, case_sensitive => 1)".ie n .Sh "$count\fP = \f(CW$prof\->exclude(key1 => qr/^SELECT/i)".el .Sh "\f(CW$count\fP = \f(CW$prof\fP\->exclude(key1 => qr/^SELECT/i)".IX Subsection "$count = $prof->exclude(key1 => qr/^SELECT/i)"Removes records from the data set that match the given string orregular expression.  This method modifies the data in a permanentfashion \- use \fIclone()\fR first to maintain the original data after\&\fIexclude()\fR.  Returns the number of nodes left in the profile data set..ie n .Sh "$count\fP = \f(CW$prof\->match(key2 => ""disconnect"")".el .Sh "\f(CW$count\fP = \f(CW$prof\fP\->match(key2 => ``disconnect'')".IX Subsection "$count = $prof->match(key2 => disconnect)".ie n .Sh "$count\fP = \f(CW$prof\->match(key2 => ""disconnect"", case_sensitive => 1)".el .Sh "\f(CW$count\fP = \f(CW$prof\fP\->match(key2 => ``disconnect'', case_sensitive => 1)".IX Subsection "$count = $prof->match(key2 => disconnect, case_sensitive => 1)".ie n .Sh "$count\fP = \f(CW$prof\->match(key1 => qr/^SELECT/i)".el .Sh "\f(CW$count\fP = \f(CW$prof\fP\->match(key1 => qr/^SELECT/i)".IX Subsection "$count = $prof->match(key1 => qr/^SELECT/i)"Removes records from the data set that do not match the given stringor regular expression.  This method modifies the data in a permanentfashion \- use \fIclone()\fR first to maintain the original data after\&\fImatch()\fR.  Returns the number of nodes left in the profile data set..ie n .Sh "$Data\fP = \f(CW$prof\fP\->\fIData()".el .Sh "\f(CW$Data\fP = \f(CW$prof\fP\->\fIData()\fP".IX Subsection "$Data = $prof->Data()"Returns the same Data hash structure as seen in DBI::Profile.  Thisstructure is not sorted.  The \fInodes()\fR structure probably makes moresense for most analysis..ie n .Sh "$text\fP = \f(CW$prof\->format($nodes\->[0])".el .Sh "\f(CW$text\fP = \f(CW$prof\fP\->format($nodes\->[0])".IX Subsection "$text = $prof->format($nodes->[0])"Formats a single node into a human-readable block of text..ie n .Sh "$text\fP = \f(CW$prof\->report(number => 10)".el .Sh "\f(CW$text\fP = \f(CW$prof\fP\->report(number => 10)".IX Subsection "$text = $prof->report(number => 10)"Produces a report with the given number of items..SH "AUTHOR".IX Header "AUTHOR"Sam Tregar <sam@tregar.com>.SH "COPYRIGHT AND LICENSE".IX Header "COPYRIGHT AND LICENSE"Copyright (C) 2002 Sam Tregar.PPThis program is free software; you can redistribute it and/or modifyit under the same terms as Perl 5 itself.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -