Search in sources :

Example 6 with ProfilePhase

use of com.google.devtools.build.lib.profiler.ProfilePhase in project bazel by bazelbuild.

the class MultiProfilePhaseHtml method printVisualizationCallbackJs.

/**
   * Prints the table data and JS for each phase and file.
   *
   * <p>Code must be added to the callback that is run when the Visualization library has loaded.
   */
public void printVisualizationCallbackJs() {
    lnPrint("var multiData;");
    lnPrint("var statsDiv;");
    lnPrint("var profileTable;");
    for (ProfilePhase phase : statistics.getSummaryStatistics()) {
        lnPrintf("statsDiv = document.getElementById('profile_file_stats_%s');", phase.nick);
        lnPrint("multiData = new google.visualization.DataTable();");
        lnPrint("multiData.addColumn('string', 'File');");
        lnPrint("multiData.addColumn('number', 'total');");
        PhaseStatistics summaryPhaseStatistics = statistics.getSummaryPhaseStatistics(phase);
        for (ProfilerTask taskType : summaryPhaseStatistics) {
            lnPrintf("multiData.addColumn('number', '%s %%');", taskType.name());
        }
        lnPrint("multiData.addRows([");
        down();
        for (Path file : statistics) {
            EnumMap<ProfilePhase, PhaseStatistics> phases = statistics.getPhaseStatistics(file);
            PhaseStatistics phaseStatistics = phases.get(phase);
            lnPrintf("['%s', ", file);
            long phaseDuration = phaseStatistics.getPhaseDurationNanos();
            printf("{v:%d, f:'%s'}, ", phaseDuration, TimeUtilities.prettyTime(phaseDuration));
            for (ProfilerTask taskType : summaryPhaseStatistics) {
                if (phaseStatistics.wasExecuted(taskType)) {
                    double relative = phaseStatistics.getTotalRelativeDuration(taskType);
                    printf("{v:%.4f, f:'%.3f %%'}, ", relative, relative * 100);
                } else {
                    print("0, ");
                }
            }
            print("],");
        }
        lnPrint("]);");
        up();
        lnPrint("profileTable = new google.visualization.Table(statsDiv);");
        lnPrint("profileTable.draw(multiData, {showRowNumber: true, width: '100%%'});");
    }
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) ProfilerTask(com.google.devtools.build.lib.profiler.ProfilerTask) ProfilePhase(com.google.devtools.build.lib.profiler.ProfilePhase) PhaseStatistics(com.google.devtools.build.lib.profiler.statistics.PhaseStatistics)

Example 7 with ProfilePhase

use of com.google.devtools.build.lib.profiler.ProfilePhase in project bazel by bazelbuild.

the class MultiProfilePhaseHtml method printHtmlBody.

/**
   * Prints divs for the tables of statistics for profile files and their phases.
   */
void printHtmlBody() {
    lnPrint("<a name='profile_file_stats'/>");
    lnElement("h3", "Profile File Statistics");
    lnOpen("div", "class", "profiles-tables", "id", "profile_file_stats");
    for (ProfilePhase phase : statistics.getSummaryStatistics()) {
        lnOpen("div");
        lnElement("h4", phase.nick);
        lnElement("div", "class", "profiles-table", "id", "profile_file_stats_" + phase.nick);
        lnClose();
    }
    // div
    lnClose();
}
Also used : ProfilePhase(com.google.devtools.build.lib.profiler.ProfilePhase)

Example 8 with ProfilePhase

use of com.google.devtools.build.lib.profiler.ProfilePhase in project bazel by bazelbuild.

the class PhaseHtml method print.

/**
   * Print tables from {@link #phaseSummaryStats} and {@link #phaseStatistics} side by side.
   */
public void print() {
    printPhaseSummaryStatistics();
    for (ProfilePhase phase : Arrays.asList(ProfilePhase.INIT, ProfilePhase.LOAD, ProfilePhase.ANALYZE)) {
        PhaseStatistics statistics = phaseStatistics.get(phase);
        if (statistics == null || !statistics.wasExecuted()) {
            continue;
        }
        printPhaseStatistics(statistics);
    }
    printExecutionPhaseStatistics();
    lnElement("div", "style", "clear: both;");
}
Also used : ProfilePhase(com.google.devtools.build.lib.profiler.ProfilePhase) PhaseStatistics(com.google.devtools.build.lib.profiler.statistics.PhaseStatistics)

Example 9 with ProfilePhase

use of com.google.devtools.build.lib.profiler.ProfilePhase in project bazel by bazelbuild.

the class PhaseText method printPhaseSummaryStatistics.

/**
   * Print a table for the phase overview with runtime and runtime percentage per phase and total.
   */
private void printPhaseSummaryStatistics() {
    print("\n=== PHASE SUMMARY INFORMATION ===\n");
    for (ProfilePhase phase : phaseSummaryStats) {
        long phaseDuration = phaseSummaryStats.getDurationNanos(phase);
        double relativeDuration = phaseSummaryStats.getRelativeDuration(phase);
        lnPrintf(THREE_COLUMN_FORMAT, "Total " + phase.nick + " phase time", TimeUtilities.prettyTime(phaseDuration), prettyPercentage(relativeDuration));
    }
    lnPrintf(THREE_COLUMN_FORMAT, "Total run time", TimeUtilities.prettyTime(phaseSummaryStats.getTotalDuration()), "100.00%");
    printLn();
}
Also used : ProfilePhase(com.google.devtools.build.lib.profiler.ProfilePhase)

Aggregations

ProfilePhase (com.google.devtools.build.lib.profiler.ProfilePhase)9 PhaseStatistics (com.google.devtools.build.lib.profiler.statistics.PhaseStatistics)4 ProfileInfo (com.google.devtools.build.lib.profiler.ProfileInfo)3 Path (com.google.devtools.build.lib.vfs.Path)3 IOException (java.io.IOException)2 EnumMap (java.util.EnumMap)2 ProfilerTask (com.google.devtools.build.lib.profiler.ProfilerTask)1 PhaseText (com.google.devtools.build.lib.profiler.output.PhaseText)1 CriticalPathStatistics (com.google.devtools.build.lib.profiler.statistics.CriticalPathStatistics)1 MultiProfileStatistics (com.google.devtools.build.lib.profiler.statistics.MultiProfileStatistics)1 PhaseSummaryStatistics (com.google.devtools.build.lib.profiler.statistics.PhaseSummaryStatistics)1 BufferedOutputStream (java.io.BufferedOutputStream)1 PrintStream (java.io.PrintStream)1