use of com.google.devtools.build.lib.profiler.ProfilerTask in project bazel by bazelbuild.
the class DetailedChartCreator method create.
@Override
public Chart create() {
Chart chart = new Chart();
CommonChartCreator.createCommonChartItems(chart, info);
createTypes(chart);
// calculate the critical path
EnumSet<ProfilerTask> typeFilter = EnumSet.noneOf(ProfilerTask.class);
CriticalPathEntry criticalPath = info.getCriticalPath(typeFilter);
info.analyzeCriticalPath(typeFilter, criticalPath);
for (Task task : info.allTasksById) {
String label = task.type.description + ": " + task.getDescription();
ChartBarType type = chart.lookUpType(task.type.description);
long stop = task.startTime + task.durationNanos;
CriticalPathEntry entry = null;
// for top level tasks, check if they are on the critical path
if (task.parentId == 0 && criticalPath != null) {
entry = info.getNextCriticalPathEntryForTask(criticalPath, task);
// find next top-level entry
if (entry != null) {
CriticalPathEntry nextEntry = entry.next;
while (nextEntry != null && nextEntry.task.parentId != 0) {
nextEntry = nextEntry.next;
}
if (nextEntry != null) {
// time is start and not stop as we traverse the critical back backwards
chart.addVerticalLine(task.threadId, nextEntry.task.threadId, task.startTime);
}
}
}
chart.addBar(task.threadId, task.startTime, stop, type, (entry != null), label);
}
return chart;
}
use of com.google.devtools.build.lib.profiler.ProfilerTask 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.ProfilerTask in project bazel by bazelbuild.
the class PhaseHtml method printTimingDistribution.
/**
* Print the table rows for the {@link ProfilerTask} types and their execution times.
*/
private void printTimingDistribution(PhaseStatistics phaseStat) {
if (!phaseStat.isEmpty()) {
lnOpen("tr");
element("td", "class", "left", "colspan", "4", "Total time (across all threads) spent on:");
// tr
close();
lnOpen("tr");
element("th", "Type");
element("th", "Total");
element("th", "Count");
element("th", "Average");
// tr
close();
for (ProfilerTask taskType : phaseStat) {
lnOpen("tr", "class", "phase-task-statistics");
element("td", taskType);
element("td", prettyPercentage(phaseStat.getTotalRelativeDuration(taskType)));
element("td", phaseStat.getCount(taskType));
element("td", TimeUtilities.prettyTime(phaseStat.getMeanDuration(taskType)));
// tr
close();
}
}
}
use of com.google.devtools.build.lib.profiler.ProfilerTask in project bazel by bazelbuild.
the class PhaseText method printTimingDistribution.
/**
* Prints a table of task types and their relative total and average execution time as well as
* how many tasks of each type there were
*/
private void printTimingDistribution(PhaseStatistics stats) {
lnPrint("Total time (across all threads) spent on:");
lnPrintf("%18s %8s %8s %11s", "Type", "Total", "Count", "Average");
for (ProfilerTask type : stats) {
lnPrintf("%18s %8s %8d %11s", type.toString(), prettyPercentage(stats.getTotalRelativeDuration(type)), stats.getCount(type), TimeUtilities.prettyTime(stats.getMeanDuration(type)));
}
}
use of com.google.devtools.build.lib.profiler.ProfilerTask in project bazel by bazelbuild.
the class ProfileCommand method dumpRaw.
private void dumpRaw(ProfileInfo.Task task, PrintStream out) {
StringBuilder aggregateString = new StringBuilder();
ProfileInfo.AggregateAttr[] stats = task.getStatAttrArray();
for (ProfilerTask type : ProfilerTask.values()) {
ProfileInfo.AggregateAttr attr = stats[type.ordinal()];
if (attr != null) {
aggregateString.append(type.toString().toLowerCase()).append(",").append(attr.count).append(",").append(attr.totalTime).append(" ");
}
}
out.println(Joiner.on('|').join(task.threadId, task.id, task.parentId, task.startTime, task.durationNanos, aggregateString.toString().trim(), task.type, task.getDescription()));
}
Aggregations