diff options
author | Leif Åstrand <leif@vaadin.com> | 2013-02-28 13:10:09 +0200 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2013-03-01 16:45:52 +0200 |
commit | d6cf871c7d3cd7e48db3450b02361e24fe652670 (patch) | |
tree | 51f466aba61b28ba1e250df33e2548dadffc4aa4 /client | |
parent | 7f9e51e0e31c5c0a699c7ca486aaf993d5aec347 (diff) | |
download | vaadin-framework-d6cf871c7d3cd7e48db3450b02361e24fe652670.tar.gz vaadin-framework-d6cf871c7d3cd7e48db3450b02361e24fe652670.zip |
Add bootstrap performance measuring support (#11188)
svn changeset:25664/svn branch:6.8
Conflicts:
client/src/com/vaadin/client/ApplicationConnection.java
uitest/src/com/vaadin/tests/performance/BasicPerformanceTest.java
uitest/src/com/vaadin/tests/util/TestUtils.java
Change-Id: I699e7b47ad5a62b67dbdf1004da5e5daf009ba25
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/ApplicationConnection.java | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java index 1a637e3161..ab9f95e8fd 100644 --- a/client/src/com/vaadin/client/ApplicationConnection.java +++ b/client/src/com/vaadin/client/ApplicationConnection.java @@ -16,7 +16,7 @@ package com.vaadin.client; -import java.util.ArrayList; +import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.HashMap; @@ -500,6 +500,7 @@ public class ApplicationConnection { ap.@com.vaadin.client.ApplicationConnection::totalProcessingTime ]; pd = pd.concat(ap.@com.vaadin.client.ApplicationConnection::serverTimingInfo); + pd[pd.length] = ap.@com.vaadin.client.ApplicationConnection::bootstrapTime; return pd; }); @@ -513,6 +514,16 @@ public class ApplicationConnection { $wnd.vaadin.clients[TTAppId] = client; }-*/; + private static native final int calculateBootstrapTime() + /*-{ + if ($wnd.performance && $wnd.performance.timing) { + return (new Date).getTime() - $wnd.performance.timing.responseStart; + } else { + // performance.timing not supported + return -1; + } + }-*/; + /** * Helper for tt initialization */ @@ -948,6 +959,15 @@ public class ApplicationConnection { protected int totalProcessingTime; /** + * Holds the time it took to load the page and render the first view. 0 + * means that this value has not yet been calculated because the first view + * has not yet been rendered (or that your browser is very fast). -1 means + * that the browser does not support the performance.timing feature used to + * get this measurement. + */ + private int bootstrapTime; + + /** * Holds the timing information from the server-side. How much time was * spent servicing the last request and how much time has been spent * servicing the session so far. These values are always one request behind, @@ -1512,6 +1532,9 @@ public class ApplicationConnection { lastProcessingTime = (int) ((new Date().getTime()) - start .getTime()); totalProcessingTime += lastProcessingTime; + if (bootstrapTime == 0) { + bootstrapTime = calculateBootstrapTime(); + } VConsole.log(" Processing time was " + String.valueOf(lastProcessingTime) + "ms for " |