summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2013-03-01 18:17:57 +0200
committerVaadin Code Review <review@vaadin.com>2013-03-06 09:23:31 +0000
commit276e6fc6c1d2643c77d0e4abea8cf862cd8b9718 (patch)
tree102101553e9ca028626282a38c1e1f041dd8af7f /client
parent313c5c2aea0e38e6cf30d53b1b2e863a3d09f37c (diff)
downloadvaadin-framework-276e6fc6c1d2643c77d0e4abea8cf862cd8b9718.tar.gz
vaadin-framework-276e6fc6c1d2643c77d0e4abea8cf862cd8b9718.zip
Add performance.timing support to Profiler (#11188)
Change-Id: I3fb14b1280a1ee8bfaa2aeab87b40c374d2e4443
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/client/ApplicationConnection.java3
-rw-r--r--client/src/com/vaadin/client/Profiler.java57
2 files changed, 60 insertions, 0 deletions
diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java
index ab9f95e8fd..2610530a80 100644
--- a/client/src/com/vaadin/client/ApplicationConnection.java
+++ b/client/src/com/vaadin/client/ApplicationConnection.java
@@ -1534,6 +1534,9 @@ public class ApplicationConnection {
totalProcessingTime += lastProcessingTime;
if (bootstrapTime == 0) {
bootstrapTime = calculateBootstrapTime();
+ if (Profiler.isEnabled() && bootstrapTime != -1) {
+ Profiler.logBootstrapTimings();
+ }
}
VConsole.log(" Processing time was "
diff --git a/client/src/com/vaadin/client/Profiler.java b/client/src/com/vaadin/client/Profiler.java
index be26da859f..15de339572 100644
--- a/client/src/com/vaadin/client/Profiler.java
+++ b/client/src/com/vaadin/client/Profiler.java
@@ -362,4 +362,61 @@ public class Profiler {
return false;
}
+ /**
+ * Outputs the time passed since various events recored in
+ * performance.timing if supported by the browser.
+ */
+ public static void logBootstrapTimings() {
+ if (isEnabled()) {
+ double now = Duration.currentTimeMillis();
+
+ StringBuilder stringBuilder = new StringBuilder(
+ "Time since window.performance.timing events");
+ SimpleTree tree = new SimpleTree(stringBuilder.toString());
+
+ String[] keys = new String[] { "navigationStart",
+ "unloadEventStart", "unloadEventEnd", "redirectStart",
+ "redirectEnd", "fetchStart", "domainLookupStart",
+ "domainLookupEnd", "connectStart", "connectEnd",
+ "requestStart", "responseStart", "responseEnd",
+ "domLoading", "domInteractive",
+ "domContentLoadedEventStart", "domContentLoadedEventEnd",
+ "domComplete", "loadEventStart", "loadEventEnd" };
+
+ for (String key : keys) {
+ double value = getPerformanceTiming(key);
+ if (value == 0) {
+ // Ignore missing value
+ continue;
+ }
+ String text = key + ": " + (now - value);
+ tree.add(new Label(text));
+ stringBuilder.append("\n * ");
+ stringBuilder.append(text);
+ }
+
+ if (tree.getWidgetCount() == 0) {
+ VConsole.log("Bootstrap timings not supported, please ensure your browser supports performance.timing");
+ return;
+ }
+
+ Console implementation = VConsole.getImplementation();
+ if (implementation instanceof VDebugConsole) {
+ VDebugConsole console = (VDebugConsole) implementation;
+ console.showTree(tree, stringBuilder.toString());
+ } else {
+ VConsole.log(stringBuilder.toString());
+ }
+ }
+ }
+
+ private static final native double getPerformanceTiming(String name)
+ /*-{
+ if ($wnd.performance && $wnd.performance.timing && $wnd.performance.timing[name]) {
+ return $wnd.performance.timing[name];
+ } else {
+ return 0;
+ }
+ }-*/;
+
}