#!/usr/bin/env perl
##########################################################
## This script is part of the Devel::NYTProf distribution
##
## Copyright, contact and other information can be found
## at the bottom of this file, or by going to:
## http://search.cpan.org/~akaplan/Devel-NYTProf
##
###########################################################
use warnings;
use strict;
use Carp;
use Getopt::Long;
use Devel::NYTProf::Reader;
our $VERSION = 1.00;
# These control the limits for what the script will consider ok to severe times
# specified in standard deviations from the mean time
use constant SEVERITY_SEVERE => 2.0; # above this deviation, a bottleneck
use constant SEVERITY_BAD => 1.0;
use constant SEVERITY_GOOD => 0.5; # within this deviation, okay
use constant NUMERIC_PRECISION => 5;
my %opt;
GetOptions(\%opt, qw/file|f=s delete|d out|o=s help|h/);
if (defined($opt{help})) {
&usage;
exit;
}
# handle file selection option
if (! defined($opt{file})) {
$opt{file} = 'nytprof.out';
}
if (! -r $opt{file}) {
die "Unable to access $opt{file}\n";
}
# handle handle output location
if (! defined($opt{out})) {
$opt{out} = './profiler';
}
if (! -r $opt{file}) {
die "Unable to access output directory $opt{file}\n";
}
# handle deleting old db's
if (defined($opt{'delete'})) {
_delete();
}
print "Generating report...\n";
my $reporter = new Devel::NYTProf::Reader($opt{file});
# place to store this crap
$reporter->outputDir($opt{out});
# set formatting for html
$reporter->setParam('header', get_header("Profile: !~FILENAME~!").
"
File Profile
| File | !~FILENAME~! |
Total Calls | !~TOTAL_CALLS~!
| \n
Total Time | !~TOTAL_TIME~!
seconds | \n
");
$reporter->setParam('taintmsg',
"WARNING!
\n
The source file used to generate this report was modified
after the profiler database was generated. The database might be out of sync, you should regenerate it. This page might not make any sense!
\n");
$reporter->setParam('datastart', "
| Line | Calls | Time | Times/Call | Code |
\n");
$reporter->setParam('footer', '