Devel-NYTProf

 view release on metacpan or  search on metacpan

bin/nytprofhtml  view on Meta::CPAN

    my $html = join ' • ', map {
        my $mode = $mode_ref->{$_};

        if ($mode eq $level) {
            qq{<span class="mode_btn mode_btn_selected">$mode view</span>};
        }
        else {
            my $mode_file = $file;

            # replace the mode specifier in the output file name -- file-name-MODE.html
            $mode_file =~ s/(.*-).*?\.html/$1$mode.html/o;

            qq{<span class="mode_btn"><a href="$mode_file">$mode view</a></span>};
        }
    } keys %$mode_ref;

    return qq{<span>&laquo;&emsp;$html&emsp;&raquo;</span>};
}


sub get_footer {
    my ($profile) = @_;
    my $version = $Devel::NYTProf::Core::VERSION;

    my $js = '';
    if (@on_ready_js) {
        # XXX I've no idea why this workaround is needed (or works).
        # without it the file table on the index page isn't sortable
        @on_ready_js = reverse @on_ready_js;

        $js = sprintf q{
            <script type="text/javascript">
              $(document).ready(function() { %s } );
            </script>
        }, join("\n", '', @on_ready_js, '');
        @on_ready_js = ();
    };

    # spacing so links to #line near can put right line at top near the bottom of the report
    my $spacing = "<br />" x 10;
    return qq{
        $js
        <div class="footer">Report produced by the
        <a href="http://metacpan.org/release/Devel-NYTProf/">NYTProf $version</a>
        Perl profiler, developed by
        <a href="http://www.linkedin.com/in/timbunce">Tim Bunce</a> based on
        work by Adam Kaplan and Salvador Fandiño García.
        </div>
        $spacing
    };
}

# returns the generic header string.  Here only to make the code more readable.
sub get_html_header {
    my $title = shift || "Profile Index - NYTProf";
    my $opts = shift || {};

    $title = _escape_html($title);

    my $html = <<EOD;
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
EOD
    $html = "<html>" if $opts->{not_xhtml};
    $html .= <<EOD;
<!--
This file was generated by Devel::NYTProf version $Devel::NYTProf::Core::VERSION
-->
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="Content-Language" content="en-us" />
    <meta name="robots" content="noindex,nofollow" />
    <title>$title</title>
EOD

    $html .= qq{    <link rel="stylesheet" type="text/css" href="style.css" />\n}
        unless $opts->{skip_style};

    if (my $css = $opts->{add_jit}) {
        $html .= qq{    <link rel="stylesheet" type="text/css" href="js/jit/$css.css" />\n};
        $html .= qq{    <script language="JavaScript" src="js/jit/jit.js"></script>\n};
    }

    $html .= <<'EOD' unless $opts->{skip_jquery};
    <script type="text/javascript" src="js/jquery-min.js"></script>

    <script type="text/javascript" src="js/jquery.floatThead.min.js"></script>
    <script type="text/javascript" src="js/jquery.tablesorter.min.js"></script>
    <link rel="stylesheet" type="text/css" href="js/style-tablesorter.css" />
    <script type="text/javascript">
    // when a column is first clicked on to sort it, use descending order
    // XXX doesn't seem to work (and not just because the tablesorter formatSortingOrder() is broken)
    $.tablesorter.defaults.sortInitialOrder = "desc";
    // add parser through the tablesorter addParser method
    $.tablesorter.addParser({
        id: 'fmt_time',   // name of this parser
        is: function(s) {
            return false; // return false so this parser is not auto detected
        },
        format: function(orig) { // format data for normalization
            // console.log(orig);
            var val = orig.replace(/ns/,'');
            if (val != orig) { return val / (1000*1000*1000); }
            val = orig.replace(/[µ\xB5]s/,''); /* micro */
            if (val != orig) { return val / (1000*1000); }
            val = orig.replace(/ms/,'');
            if (val != orig) { return val / (1000); }
            val = orig.replace(/([0-9])s/,"$1");
            if (val != orig) { return val; }
            if (orig == '0') { return orig; }
            var non_number = orig.replace(/^[-+]?[0-9.]+/, '', 'g');
            console.log('no match for fmt_time of '+orig+' (units:'+non_number+' charCodeAt0:'+non_number.charCodeAt(0)+')');
            return orig;
        },
        type: 'numeric' // set type, either numeric or text
    });

    function show_fragment_target() {
        var tgt = $(':target');
        var table = tgt.closest('table.floatHeaders');
        if( tgt.is('a') && table.is('table.floatHeaders') )



( run in 1.450 second using v1.01-cache-2.11-cpan-39bf76dae61 )