new
$profile = Devel::NYTProf::Data->new( );
$profile = Devel::NYTProf::Data->new( {
filename => 'nytprof.out', # default
quiet => 0, # default, 1 to silence message
} );
Reads the specified file containing profile data written by Devel::NYTProf, aggregates the contents, and
returns the results as a blessed data structure.
dump_profile_data
$profile->dump_profile_data;
$profile->dump_profile_data( {
filehandle => \*STDOUT,
separator => "",
} );
Writes the profile data in a reasonably human friendly format to the specified "filehandle" (default
STDOUT).
For non-trivial profiles the output can be very large. As a guide, there'll be at least one line of
output for each line of code executed, plus one for each place a subroutine was called from, plus one per
subroutine.
The default format is a Data::Dumper style whitespace-indented tree. The types of data present can
depend on the options used when profiling.
If "separator" is true then instead of whitespace, each item of data is indented with the path through
the structure with "separator" used to separate the elements of the path. This format is especially
useful for grep'ing and diff'ing.
normalize_variables
$profile->normalize_variables;
Traverses the profile data structure and normalizes highly variable data, such as the time, in order that
the data can more easily be compared. This is mainly of use to the test suite.
The data normalized is:
• profile timing data: set to 0
• subroutines: timings are set to 0
• attributes, like basetime, xs_version, etc., are set to 0
• filenames: path prefixes matching absolute paths in @INC are changed to "/.../"
• filenames: eval sequence numbers, like "(re_eval 2)" are changed to 0
subs_defined_in_file
$subs_defined_hash = $profile->subs_defined_in_file( $file, $include_lines );
Returns a reference to a hash containing information about subroutines defined in a source file. The
$file argument can be an integer file id (fid) or a file path.
Returns undef if the profile contains no "sub_subinfo" data for the $file.
The keys of the returned hash are fully qualified subroutine names and the corresponding value is a hash
reference containing Devel::NYTProf::SubInfo objects.
If $include_lines is true then the hash also contains integer keys corresponding to the first line of the
subroutine. The corresponding value is a reference to an array. The array contains a hash ref for each of
the subroutines defined on that line, typically just one.
file_line_range_of_sub
($file, $fid, $first, $last, $fi) = $profile->file_line_range_of_sub("main::foo");
Returns the filename, fid, and first and last line numbers, and fileinfo object for the specified
subroutine (which must be fully qualified with a package name).
Returns an empty list if the subroutine name is not in the profile data.
The $fid return is the 'original' fid associated with the file the subroutine was created in.
The $file returned is the source file that defined the subroutine.
Subroutines that are implemented in XS have a line range of 0,0 and a possibly unknown file (if NYTProf
couldn't find a good match based on the package name).
Subroutines that were called but only returned via an exception may have a line range of undef,undef if
they're xsubs or were defined before NYTProf was enabled.
resolve_fid
$fid = $profile->resolve_fid( $file );
Returns the integer fileid that corresponds to $file.
If $file can't be found and $file looks like a positive integer then it's presumed to already be a fid
and is returned. This is used to enable other methods to work with fid or file arguments.
If $file can't be found but it uniquely matches the suffix of one of the files then that corresponding
fid is returned.