Author: gisle.aas
Date: Mon Oct 27 00:58:56 2008
New Revision: 555
Modified:
trunk/HACKING
trunk/lib/Devel/NYTProf.pm
trunk/lib/Devel/NYTProf/Apache.pm
trunk/lib/Devel/NYTProf/Data.pm
trunk/lib/Devel/NYTProf/Reader.pm
Log:
Make indentation in the documentation code samples consistent.
This is a whitespace-only change.
Modified: trunk/HACKING
==============================================================================
--- trunk/HACKING (original)
+++ trunk/HACKING Mon Oct 27 00:58:56 2008
@@ -56,17 +56,17 @@
You still need to verify the .x.new file of course!
Note: While writing a test, it is helpful to be able to run it directly,
- without the test harness. This allows you to view more output
stdout and
- stderr. Fortunately, its easy to do:
+without the test harness. This allows you to view more output stdout and
+stderr. Fortunately, its easy to do:
- perl -Mblib -MDevel::NYTProf t/test01.p
+ perl -Mblib -MDevel::NYTProf t/test01.p
- The output will be in the ./nytprof.out file.
- You can then also run the csv manually:
+The output will be in the ./nytprof.out file. You can then also run the
+csv manually:
- perl -Mblib bin/nytprofcsv
+ perl -Mblib bin/nytprofcsv
- The final file will be in ./nytprof/test01.p.csv
+The final file will be in ./nytprof/test01.p.csv
Remember, testing is VERY VERY important! Within a day or two of releasing
code, the CPAN testers will test the release on pretty much every major
platform
@@ -100,6 +100,7 @@
- to be subclassable
- to provide a subclass to manage generating CSV
- to provide a subclass to manage generating HTML
+
Then rework bin/ntyprof* to use the new subclasses
Ideally end up with a single nytprof command.
@@ -152,10 +153,12 @@
but it requires use_db_subs=1 due to perl internals. Currently unused.
Add source code of first string eval at each fid:line to report.
Add option to control saving of source code. Perhaps
-savesrc=0 - don't save any source
-savesrc=1 - save only first string eval src per distinct fid:line (default)
-savesrc=2 - save all string eval src
-savesrc=3 - save all source code, not just string evals
+
+ savesrc=0 - don't save any source
+ savesrc=1 - save only first string eval src per distinct fid:line
(default)
+ savesrc=2 - save all string eval src
+ savesrc=3 - save all source code, not just string evals
+
Also option to delete @{"_<$filename"} to release memory could be useful
for programs that doo a lot of string evals.
@@ -200,7 +203,8 @@
(using a set of #ifdef's)
Add mechanism to specify options inside the .p file, such as
-# NYTPROF=...
+
+ # NYTPROF=...
Add mechanism to specify inside the .p file that NYTProf
should not be loaded via the command line. That's needed to test
@@ -212,9 +216,11 @@
Pure css tooltips, with a :before or :after with content:, may let us add
help notes to the
counts column to describe what the count is actually a count of, without
bloating the html.
-http://meyerweb.com/eric/css/edge/popups/demo.html
-http://www.communitymx.com/content/article.cfm?page=4&cid=4E2C0
-http://www.kollermedia.at/archive/2008/03/24/easy-css-tooltip/
+
+ http://meyerweb.com/eric/css/edge/popups/demo.html
+ http://www.communitymx.com/content/article.cfm?page=4&cid=4E2C0
+ http://www.kollermedia.at/archive/2008/03/24/easy-css-tooltip/
+
The tricky/clever/new idea is that by nesting a span inside another and
using
the :before or :after on the inner one the text of the popup can reside in
css
and not html. Mind you, I've not seen anyone do this so I may be crazy :)
@@ -230,16 +236,17 @@
source line, and/or the opposite. Needs lots of thought, but it's an
interesting idea.
Investigate and fix "Unable to determine line number" cases. Here's one:
-$ NYTPROF=begin=1:blocks=1:trace=1 perl -d:NYTProf -Mstrict -e 1
-...
-New fid 1 (after 0:1 ): -e /Users/timbo/perl/mods/nytprof-trunk/-e
-New fid 2 (after 1:3 ): /usr/local/perl58-i/lib/5.8.6/strict.pm
-at 3: EVAL in different file (-e, /usr/local/perl58-i/lib/5.8.6/strict.pm)
at /usr/local/perl58-i/lib/5.8.6/strict.pm line 3.
-at 5: EVAL in different file (-e, /usr/local/perl58-i/lib/5.8.6/strict.pm)
at /usr/local/perl58-i/lib/5.8.6/strict.pm line 5.
-at 25: EVAL in different file (-e,
/usr/local/perl58-i/lib/5.8.6/strict.pm) at
/usr/local/perl58-i/lib/5.8.6/strict.pm line 25.
-at 37: EVAL in different file (-e,
/usr/local/perl58-i/lib/5.8.6/strict.pm) at
/usr/local/perl58-i/lib/5.8.6/strict.pm line 37.
-Unable to determine line number in -e.
-Unable to determine line number in -e.
+
+ $ NYTPROF=begin=1:blocks=1:trace=1 perl -d:NYTProf -Mstrict -e 1
+ ...
+ New fid 1 (after 0:1 ): -e /Users/timbo/perl/mods/nytprof-trunk/-e
+ New fid 2 (after 1:3 ): /usr/local/perl58-i/lib/5.8.6/strict.pm
+ at 3: EVAL in different file (-e,
/usr/local/perl58-i/lib/5.8.6/strict.pm) at
/usr/local/perl58-i/lib/5.8.6/strict.pm line 3.
+ at 5: EVAL in different file (-e,
/usr/local/perl58-i/lib/5.8.6/strict.pm) at
/usr/local/perl58-i/lib/5.8.6/strict.pm line 5.
+ at 25: EVAL in different file (-e,
/usr/local/perl58-i/lib/5.8.6/strict.pm) at
/usr/local/perl58-i/lib/5.8.6/strict.pm line 25.
+ at 37: EVAL in different file (-e,
/usr/local/perl58-i/lib/5.8.6/strict.pm) at
/usr/local/perl58-i/lib/5.8.6/strict.pm line 37.
+ Unable to determine line number in -e.
+ Unable to determine line number in -e.
Add option to disable statement based profiling, so you're left with
subroutine
inclusive timing. That's *really* fast and would be handy for a quick
check on
@@ -302,8 +309,9 @@
Bug or limitation?: sub calls in a continue { ... } block of a while () get
associated with the 'next;' within the loop.
Also, test sub caller location for
+
while ( foo() ) { # all calls to foo should be from here
- ...
- ... # no calls to foo() should appear here
+ ...
+ ... # no calls to foo() should appear here
}
Modified: trunk/lib/Devel/NYTProf.pm
==============================================================================
--- trunk/lib/Devel/NYTProf.pm (original)
+++ trunk/lib/Devel/NYTProf.pm Mon Oct 27 00:58:56 2008
@@ -52,14 +52,14 @@
=head1 SYNOPSIS
- # profile code and write database to ./nytprof.out
- perl -d:NYTProf some_perl.pl
+ # profile code and write database to ./nytprof.out
+ perl -d:NYTProf some_perl.pl
- # convert database into a set of html files, e.g., ./nytprof/index.html
- nytprofhtml
+ # convert database into a set of html files, e.g., ./nytprof/index.html
+ nytprofhtml
- # or into comma seperated files, e.g., ./nytprof/*.csv
- nytprofcsv
+ # or into comma seperated files, e.g., ./nytprof/*.csv
+ nytprofcsv
=head1 DESCRIPTION
@@ -166,7 +166,7 @@
Just add one line near the start of your httpd.conf file:
- PerlModule Devel::NYTProf::Apache
+ PerlModule Devel::NYTProf::Apache
By default you'll get a F</tmp/nytprof.$$.out> file for the parent process
and
a F</tmp/nytprof.$parent.out.$$> file for each worker process.
@@ -181,19 +181,19 @@
Usually you'd load Devel::NYTProf on the command line using the perl -d
option:
- perl -d:NYTProf some_perl.pl
+ perl -d:NYTProf some_perl.pl
To save typing the ':NYTProf' you could set the PERL5DB env var
- PERL5DB='use Devel::NYTProf'
+ PERL5DB='use Devel::NYTProf'
and then just perl -d would work:
- perl -d some_perl.pl
+ perl -d some_perl.pl
Or you can avoid the need to add the -d option at all by using the
C<PERL5OPT> env var:
- PERL5OPT=-d:NYTProf
+ PERL5OPT=-d:NYTProf
That's also very handy when you can't alter the perl command line being
used to
run the script you want to profile.
@@ -205,7 +205,7 @@
variable to effect multiple setting by separating the values with a C<:>.
For
example:
- export NYTPROF=trace=2:start=init:file=/tmp/nytprof.out
+ export NYTPROF=trace=2:start=init:file=/tmp/nytprof.out
=head2 addpid=1
Modified: trunk/lib/Devel/NYTProf/Apache.pm
==============================================================================
--- trunk/lib/Devel/NYTProf/Apache.pm (original)
+++ trunk/lib/Devel/NYTProf/Apache.pm Mon Oct 27 00:58:56 2008
@@ -73,9 +73,9 @@
=head1 SYNOPSIS
- # in your Apache config file with mod_perl installed
- PerlPassEnv NYTPROF
- PerlModule Devel::NYTProf::Apache
+ # in your Apache config file with mod_perl installed
+ PerlPassEnv NYTPROF
+ PerlModule Devel::NYTProf::Apache
=head1 DESCRIPTION
@@ -86,7 +86,7 @@
Devel::NYTProf::Apache is loaded> then Devel::NYTProf::Apache will issue a
warning and default it to:
- file=/tmp/nytprof.$$.out
+ file=/tmp/nytprof.$$.out
See L<Devel::NYTProf/"ENVIRONMENT VARIABLES"> for
more details on the settings effected by this environment variable.
@@ -111,10 +111,10 @@
and enable it whenever it's needed by adding C<-D NYTPROF> to the httpd
startup
command line.
- <IfDefine NYTPROF>
- MaxClients 1
- PerlModule Devel::NYTProf::Apache
- </IfDefine>
+ <IfDefine NYTPROF>
+ MaxClients 1
+ PerlModule Devel::NYTProf::Apache
+ </IfDefine>
=head1 SEE ALSO
@@ -129,9 +129,9 @@
=head1 COPYRIGHT AND LICENSE
-Copyright (C) 2008 by Adam Kaplan and The New York Times Company.
-Copyright (C) 2008 by Steve Peters.
-Copyright (C) 2008 by Tim Bunce.
+ Copyright (C) 2008 by Adam Kaplan and The New York Times Company.
+ Copyright (C) 2008 by Steve Peters.
+ Copyright (C) 2008 by Tim Bunce.
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.8 or,
Modified: trunk/lib/Devel/NYTProf/Data.pm
==============================================================================
--- trunk/lib/Devel/NYTProf/Data.pm (original)
+++ trunk/lib/Devel/NYTProf/Data.pm Mon Oct 27 00:58:56 2008
@@ -19,9 +19,9 @@
use Devel::NYTProf::Data;
- $profile = Devel::NYTProf::Data->new( { filename => 'nytprof.out' } );
+ $profile = Devel::NYTProf::Data->new( { filename => 'nytprof.out' } );
- $profile->dump_profile_data();
+ $profile->dump_profile_data();
=head1 DESCRIPTION
@@ -56,7 +56,7 @@
=head2 new
- $profile = Devel::NYTProf::Data->new( { filename => 'nytprof.out' } );
+ $profile = Devel::NYTProf::Data->new( { filename => 'nytprof.out' } );
Reads the specified file containing profile data written by
L<Devel::NYTProf>,
aggregates the contents, and returns the results as a blessed data
structure.
@@ -229,8 +229,8 @@
$profile->dump_profile_data;
$profile->dump_profile_data( {
- filehandle => \*STDOUT,
- separator => "",
+ filehandle => \*STDOUT,
+ separator => "",
} );
Writes the profile data in a reasonably human friendly format to the
sepcified
@@ -243,51 +243,51 @@
The default format is a Data::Dumper style whitespace-indented tree.
The types of data present can depend on the options used when profiling.
- {
- attribute => {
- basetime => 1207228764
- ticks_per_sec => 1000000
- xs_version => 1.13
- }
- fid_fileinfo => [
- 1: [
- 0: test01.p
- 1:
- 2:
- 3: 1
- 4: 0
- 5: 0
- 6: 0
- ]
- ]
- fid_line_time => [
- 1: [
- 2: [ 4e-06 2 ]
- 3: [ 1.2e-05 2 ]
- 7: [ 4.6e-05 4 ]
- 11: [ 2e-06 1 ]
- 16: [ 1.2e-05 1 ]
- ]
- ]
- sub_caller => {
- main::bar => {
- 1 => {
- 12 => 1 # main::bar was called by fid 1, line 12, 1 time.
- 16 => 1
- 3 => 2
- }
- }
- main::foo => {
- 1 => {
- 11 => 1
- }
- }
- }
- sub_subinfo => {
- main::bar => [ 1 6 8 762 2e-06 ]
- main::foo => [ 1 1 4 793 1.5e-06 ]
- }
- }
+ {
+ attribute => {
+ basetime => 1207228764
+ ticks_per_sec => 1000000
+ xs_version => 1.13
+ }
+ fid_fileinfo => [
+ 1: [
+ 0: test01.p
+ 1:
+ 2:
+ 3: 1
+ 4: 0
+ 5: 0
+ 6: 0
+ ]
+ ]
+ fid_line_time => [
+ 1: [
+ 2: [ 4e-06 2 ]
+ 3: [ 1.2e-05 2 ]
+ 7: [ 4.6e-05 4 ]
+ 11: [ 2e-06 1 ]
+ 16: [ 1.2e-05 1 ]
+ ]
+ ]
+ sub_caller => {
+ main::bar => {
+ 1 => {
+ 12 => 1 # main::bar was called by fid 1, line 12, 1 time.
+ 16 => 1
+ 3 => 2
+ }
+ }
+ main::foo => {
+ 1 => {
+ 11 => 1
+ }
+ }
+ }
+ sub_subinfo => {
+ main::bar => [ 1 6 8 762 2e-06 ]
+ main::foo => [ 1 1 4 793 1.5e-06 ]
+ }
+ }
If C<separator> is true then instead of whitespace, each item of data is
indented with the I<path> through the structure with C<separator> used to
@@ -671,8 +671,8 @@
=head2 subname_at_file_line
- @subname = $profile->subname_at_file_line($file, $line_number);
- $subname = $profile->subname_at_file_line($file, $line_number);
+ @subname = $profile->subname_at_file_line($file, $line_number);
+ $subname = $profile->subname_at_file_line($file, $line_number);
=cut
@@ -723,7 +723,7 @@
=head2 file_line_range_of_sub
- ($file, $fid, $first, $last) =
$profile->file_line_range_of_sub("main::foo");
+ ($file, $fid, $first, $last) =
$profile->file_line_range_of_sub("main::foo");
Returns the filename, fid, and first and last line numbers for the
specified
subroutine (which must be fully qualified with a package name).
@@ -840,12 +840,12 @@
that line was executed once, and foo and bar were imported from pkg1, then
$profile->line_calls_for_file( 'foo.pl' ) would return something like:
- {
- 42 => {
- 'pkg1::foo' => [ 1, 0.02093 ],
- 'pkg1::bar' => [ 1, 0.00154 ],
- },
- }
+ {
+ 42 => {
+ 'pkg1::foo' => [ 1, 0.02093 ],
+ 'pkg1::bar' => [ 1, 0.00154 ],
+ },
+ }
=cut
Modified: trunk/lib/Devel/NYTProf/Reader.pm
==============================================================================
--- trunk/lib/Devel/NYTProf/Reader.pm (original)
+++ trunk/lib/Devel/NYTProf/Reader.pm Mon Oct 27 00:58:56 2008
@@ -565,40 +565,40 @@
=head1 SYNOPSIS
- # This module comes with two scripts that implement it:
- #
- # nytprofhtml - create an html report with statistics highlighting
- # nytprofcsv - create a basic comma delimited report
- #
- # They are in the bin directory of your perl path, so add that to your
PATH.
- #
- # The csv script is simple, and really only provided as a starting point
- # for creating other custom reports. You should refer to the html script
- # for advanced usage and statistics.
-
- # First run some code through the profiler to generate the nytprof
database.
- perl -d:NYTProf some_perl.pl
-
- # To create an HTML report in ./nytprof
- nytprofhtml
-
- # To create a csv report in ./nytprof
- nytprofcsv
-
- # Or to generate a simple comma delimited report manually
- use Devel::NYTProf::Reader;
- my $reporter = new Devel::NYTProf::Reader('nytprof.out');
-
- # place to store the output
- $reporter->output_dir($file);
+ # This module comes with two scripts that implement it:
+ #
+ # nytprofhtml - create an html report with statistics highlighting
+ # nytprofcsv - create a basic comma delimited report
+ #
+ # They are in the bin directory of your perl path, so add that to your
PATH.
+ #
+ # The csv script is simple, and really only provided as a starting point
+ # for creating other custom reports. You should refer to the html script
+ # for advanced usage and statistics.
+
+ # First run some code through the profiler to generate the nytprof
database.
+ perl -d:NYTProf some_perl.pl
+
+ # To create an HTML report in ./nytprof
+ nytprofhtml
+
+ # To create a csv report in ./nytprof
+ nytprofcsv
+
+ # Or to generate a simple comma delimited report manually
+ use Devel::NYTProf::Reader;
+ my $reporter = new Devel::NYTProf::Reader('nytprof.out');
+
+ # place to store the output
+ $reporter->output_dir($file);
- # set other options and parameters
- $reporter->add_regexp('^\s*', ''); # trim leading spaces
+ # set other options and parameters
+ $reporter->add_regexp('^\s*', ''); # trim leading spaces
- # generate the report
- $reporter->report();
+ # generate the report
+ $reporter->report();
- # many configuration options exist. See nytprofhtml, advanced example.
+ # many configuration options exist. See nytprofhtml, advanced example.
=head1 DESCRIPTION
@@ -678,9 +678,9 @@
For example, to replace spaces, < and > with html entities, you might do:
- $reporter->add_regexp(' ', ' ');
- $reporter->add_regexp('<', '<');
- $reporter->add_regexp('>', '>');
+ $reporter->add_regexp(' ', ' ');
+ $reporter->add_regexp('<', '<');
+ $reporter->add_regexp('>', '>');
=item $reporter->set_param( $parameter, $value );
@@ -779,8 +779,8 @@
When called after calling C<$reporter-E<gt>report()>, will return a hash
containing the cumulative totals for each file.
- my $stats = $reporter->getStats();
- $stats->{FILENAME}->{time}; # might hold 0.25, the total runtime of this
file>>
+ my $stats = $reporter->getStats();
+ $stats->{FILENAME}->{time}; # might hold 0.25, the total runtime of this
file>>
Fields are time, calls, time/call, html-safe.
--~--~---------~--~----~------------~-------~--~----~
You've received this message because you are subscribed to
the Devel::NYTProf Development User group.
Group hosted at: http://groups.google.com/group/develnytprof-dev
Project hosted at: http://perl-devel-nytprof.googlecode.com
CPAN distribution: http://search.cpan.org/dist/Devel-NYTProf
To post, email: [email protected]
To unsubscribe, email: [EMAIL PROTECTED]
-~----------~----~----~----~------~----~------~--~---