diff options
author | Klaas Boesche <klaasb@google.com> | 2015-10-05 11:32:49 +0000 |
---|---|---|
committer | Damien Martin-Guillerez <dmarting@google.com> | 2015-10-05 15:15:52 +0000 |
commit | 19e00fba81ee9caaff24436262430bbe4a2f17f2 (patch) | |
tree | 9e23232e5f3cfeb9b0fcbf17d71b495a7781eadf /src/main | |
parent | 921407688c0c66bc61a7f19b4a8c4d6eeace1c58 (diff) |
Add options for reducing the size of the HTML output: --[no]chart for omitting the Gantt-style charts of all tasks and --[no]histograms to omit Skylark histograms which require adding huge amounts of data to the output. Especially necessary when combining data from multiple profile files.
--
MOS_MIGRATED_REVID=104646190
Diffstat (limited to 'src/main')
3 files changed, 100 insertions, 41 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/profiler/output/HtmlCreator.java b/src/main/java/com/google/devtools/build/lib/profiler/output/HtmlCreator.java index 9f70e34dd8..ab703ac2fd 100644 --- a/src/main/java/com/google/devtools/build/lib/profiler/output/HtmlCreator.java +++ b/src/main/java/com/google/devtools/build/lib/profiler/output/HtmlCreator.java @@ -37,7 +37,7 @@ import java.util.EnumMap; */ public final class HtmlCreator extends HtmlPrinter { - private final Chart chart; + private final Optional<Chart> chart; private final HtmlChartVisitor chartVisitor; private final Optional<SkylarkHtml> skylarkStats; private final String title; @@ -46,21 +46,32 @@ public final class HtmlCreator extends HtmlPrinter { private HtmlCreator( PrintStream out, String title, - Chart chart, + Optional<Chart> chart, Optional<SkylarkHtml> skylarkStats, int htmlPixelsPerSecond, PhaseHtml phases) { super(out); this.title = title; this.chart = chart; - chartVisitor = new HtmlChartVisitor(out, htmlPixelsPerSecond); this.skylarkStats = skylarkStats; this.phases = phases; + chartVisitor = new HtmlChartVisitor(out, htmlPixelsPerSecond); + } + + public HtmlCreator( + PrintStream out, + String title, + Optional<SkylarkHtml> skylarkStats, + int htmlPixelsPerSecond, + PhaseHtml phases) { + this(out, title, Optional.<Chart>absent(), skylarkStats, htmlPixelsPerSecond, phases); } private void print() { htmlFrontMatter(); - chart.accept(chartVisitor); + if (chart.isPresent()) { + chart.get().accept(chartVisitor); + } element("a", "name", "Statistics"); element("h2", "Statistics"); @@ -76,7 +87,9 @@ public final class HtmlCreator extends HtmlPrinter { lnOpen("html"); lnOpen("head"); lnElement("title", title); - chartVisitor.printCss(chart.getSortedTypes()); + if (chart.isPresent()) { + chartVisitor.printCss(chart.get().getSortedTypes()); + } phases.printCss(); @@ -106,20 +119,27 @@ public final class HtmlCreator extends HtmlPrinter { EnumMap<ProfilePhase, PhaseStatistics> statistics, boolean detailed, int htmlPixelsPerSecond, - int vfsStatsLimit) + int vfsStatsLimit, + boolean generateChart, + boolean generateHistograms) throws IOException { try (PrintStream out = new PrintStream(new BufferedOutputStream(htmlFile.getOutputStream()))) { - ChartCreator chartCreator; PhaseHtml phaseHtml = new PhaseHtml(out, phaseSummaryStats, statistics, vfsStatsLimit); - Optional<SkylarkHtml> skylarkStats; + Optional<SkylarkHtml> skylarkStats = Optional.absent(); + Optional<Chart> chart = Optional.absent(); if (detailed) { - skylarkStats = Optional.of(new SkylarkHtml(out, new SkylarkStatistics(info))); - chartCreator = new DetailedChartCreator(info); - } else { - chartCreator = new AggregatingChartCreator(info); - skylarkStats = Optional.absent(); + skylarkStats = + Optional.of(new SkylarkHtml(out, new SkylarkStatistics(info), generateHistograms)); + } + if (generateChart) { + ChartCreator chartCreator; + if (detailed) { + chartCreator = new DetailedChartCreator(info); + } else { + chartCreator = new AggregatingChartCreator(info); + } + chart = Optional.of(chartCreator.create()); } - Chart chart = chartCreator.create(); new HtmlCreator(out, info.comment, chart, skylarkStats, htmlPixelsPerSecond, phaseHtml) .print(); } diff --git a/src/main/java/com/google/devtools/build/lib/profiler/output/SkylarkHtml.java b/src/main/java/com/google/devtools/build/lib/profiler/output/SkylarkHtml.java index b2768bde80..cf7de68ced 100644 --- a/src/main/java/com/google/devtools/build/lib/profiler/output/SkylarkHtml.java +++ b/src/main/java/com/google/devtools/build/lib/profiler/output/SkylarkHtml.java @@ -35,10 +35,16 @@ public final class SkylarkHtml extends HtmlPrinter { private static final int NUM_LOCATION_CHARS_UNABBREVIATED = 40; private final SkylarkStatistics stats; + private final boolean printHistograms; public SkylarkHtml(PrintStream out, SkylarkStatistics stats) { + this(out, stats, true); + } + + public SkylarkHtml(PrintStream out, SkylarkStatistics stats, boolean printHistograms) { super(out); this.stats = stats; + this.printHistograms = printHistograms; } /** @@ -80,27 +86,32 @@ public final class SkylarkHtml extends HtmlPrinter { tableVar, stats.getBuiltinTotalNanos()); - printHistogramData(); + if (printHistograms) { + printHistogramData(); - lnPrint("document.querySelector('#user-close').onclick = function() {"); - lnPrint(" document.querySelector('#user-histogram').style.display = 'none';"); - lnPrint("};"); - lnPrint("document.querySelector('#builtin-close').onclick = function() {"); - lnPrint(" document.querySelector('#builtin-histogram').style.display = 'none';"); - lnPrint("};"); - up(); - lnPrint("};"); + lnPrint("document.querySelector('#user-close').onclick = function() {"); + lnPrint(" document.querySelector('#user-histogram').style.display = 'none';"); + lnPrint("};"); + lnPrint("document.querySelector('#builtin-close').onclick = function() {"); + lnPrint(" document.querySelector('#builtin-histogram').style.display = 'none';"); + lnPrint("};"); + } - lnPrint("var options = {"); - down(); - lnPrint("isStacked: true,"); - lnPrint("legend: { position: 'none' },"); - lnPrint("hAxis: { },"); - lnPrint("histogram: { lastBucketPercentile: 5 },"); - lnPrint("vAxis: { title: '# calls', viewWindowMode: 'pretty', gridlines: { count: -1 } }"); up(); lnPrint("};"); + if (printHistograms) { + lnPrint("var options = {"); + down(); + lnPrint("isStacked: true,"); + lnPrint("legend: { position: 'none' },"); + lnPrint("hAxis: { },"); + lnPrint("histogram: { lastBucketPercentile: 5 },"); + lnPrint("vAxis: { title: '# calls', viewWindowMode: 'pretty', gridlines: { count: -1 } }"); + up(); + lnPrint("};"); + } + lnPrint("function selectHandler(category) {"); down(); lnPrint("return function() {"); @@ -110,15 +121,22 @@ public final class SkylarkHtml extends HtmlPrinter { lnPrint("var item = selection[0];"); lnPrintf("var loc = %s[category].getValue(item.row, 0);", dataVar); lnPrintf("var func = %s[category].getValue(item.row, 1);", dataVar); - lnPrint("var key = loc + '#' + func;"); - lnPrint("var histData = histogramData[category][key];"); - lnPrint("var fnOptions = JSON.parse(JSON.stringify(options));"); - lnPrint("fnOptions.title = loc + ' - ' + func;"); - lnPrint("var chartDiv = document.getElementById(category+'-chart');"); - lnPrint("var chart = new google.visualization.Histogram(chartDiv);"); lnPrint("var histogramDiv = document.getElementById(category+'-histogram');"); - lnPrint("histogramDiv.style.display = 'block';"); - lnPrint("chart.draw(histData, fnOptions);"); + if (printHistograms) { + lnPrint("var key = loc + '#' + func;"); + lnPrint("var histData = histogramData[category][key];"); + lnPrint("var fnOptions = JSON.parse(JSON.stringify(options));"); + lnPrint("fnOptions.title = loc + '#' + func;"); + lnPrint("var chartDiv = document.getElementById(category+'-chart');"); + lnPrint("var chart = new google.visualization.Histogram(chartDiv);"); + lnPrint("histogramDiv.style.display = 'block';"); + lnPrint("chart.draw(histData, fnOptions);"); + } else { + lnPrint("var chartDiv = document.getElementById(category+'-chart');"); + lnPrint("chartDiv.innerHTML = '<h3>' + loc + '#' + func + '</h3>';"); + lnPrint("chartDiv.style.height = 'auto';"); + lnPrint("histogramDiv.style.display = 'block';"); + } up(); lnPrint("}"); up(); @@ -228,14 +246,14 @@ public final class SkylarkHtml extends HtmlPrinter { lnElement("h4", "User-Defined function execution time"); lnOpen("div", "class", "skylark-histogram", "id", "user-histogram"); lnElement("div", "class", "skylark-chart", "id", "user-chart"); - lnElement("button", "id", "user-close", "Hide histogram"); + lnElement("button", "id", "user-close", "Hide"); lnClose(); // div user-histogram lnElement("div", "class", "skylark-table", "id", "user_function_stats"); lnElement("h4", "Builtin function execution time"); lnOpen("div", "class", "skylark-histogram", "id", "builtin-histogram"); lnElement("div", "class", "skylark-chart", "id", "builtin-chart"); - lnElement("button", "id", "builtin-close", "Hide histogram"); + lnElement("button", "id", "builtin-close", "Hide"); lnClose(); // div builtin-histogram lnElement("div", "class", "skylark-table", "id", "builtin_function_stats"); } diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/ProfileCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/ProfileCommand.java index 1a21b9ca0f..115236ee5d 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/commands/ProfileCommand.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/ProfileCommand.java @@ -65,6 +65,15 @@ public final class ProfileCommand implements BlazeCommand { } public static class ProfileOptions extends OptionsBase { + @Option( + name = "chart", + defaultValue = "true", + help = + "If --nochart is present, do not include the task chart with --html_details." + + " The default is --chart." + ) + public boolean chart; + @Option(name = "dump", abbrev='d', converter = DumpConverter.class, @@ -97,6 +106,16 @@ public final class ProfileCommand implements BlazeCommand { public boolean htmlDetails; @Option( + name = "html_histograms", + defaultValue = "false", + help = + "If --html_histograms and --html_details is present, the HTML output will display" + + " histograms for Skylark functions clicked in the statistics table. This will" + + " increase file size massively." + ) + public boolean htmlHistograms; + + @Option( name = "task_tree", defaultValue = "null", converter = Converters.RegexPatternConverter.class, @@ -194,7 +213,9 @@ public final class ProfileCommand implements BlazeCommand { phaseStatistics, opts.htmlDetails, opts.htmlPixelsPerSecond, - opts.vfsStatsLimit); + opts.vfsStatsLimit, + opts.chart, + opts.htmlHistograms); } else { CriticalPathStatistics critPathStats = new CriticalPathStatistics(info); new PhaseText( |