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%%'});");
}
}
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();
}
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;");
}
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();
}
Aggregations