diff options
author | Henri Sara <hesara@vaadin.com> | 2013-08-20 12:21:18 +0300 |
---|---|---|
committer | Henri Sara <hesara@vaadin.com> | 2013-08-20 12:21:18 +0300 |
commit | b5a212a8c87a7370c385aeec22ea98a58fc7b051 (patch) | |
tree | aa6b6d9393f4f01199caef4e3db07584a575434c /client | |
parent | 61dbe9caa1daee4ce2ddddc38de1ec604c464ef5 (diff) | |
download | vaadin-framework-b5a212a8c87a7370c385aeec22ea98a58fc7b051.tar.gz vaadin-framework-b5a212a8c87a7370c385aeec22ea98a58fc7b051.zip |
Report min and max times from Profiler (#12409)
Change-Id: Ifb88038baf9c1b9c872840030dcaefd7b8488f64
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/Profiler.java | 4 | ||||
-rw-r--r-- | client/src/com/vaadin/client/debug/internal/ProfilerSection.java | 54 |
2 files changed, 48 insertions, 10 deletions
diff --git a/client/src/com/vaadin/client/Profiler.java b/client/src/com/vaadin/client/Profiler.java index caa512b34e..bcbf8279f3 100644 --- a/client/src/com/vaadin/client/Profiler.java +++ b/client/src/com/vaadin/client/Profiler.java @@ -224,7 +224,7 @@ public class Profiler { && eventName.equals(stack.get(stack.size() - 2).getName()) && !isBeginEvent) { // back out of sub event - stackTop.addTime(gwtStatsEvent.getMillis()); + stackTop.leave(gwtStatsEvent.getMillis()); stack.removeLast(); stackTop = stack.getLast(); @@ -240,7 +240,7 @@ public class Profiler { return; } Node previousStackTop = stack.removeLast(); - previousStackTop.addTime(gwtStatsEvent.getMillis()); + previousStackTop.leave(gwtStatsEvent.getMillis()); } else { if (!inEvent) { stackTop = stackTop.enterChild(eventName, diff --git a/client/src/com/vaadin/client/debug/internal/ProfilerSection.java b/client/src/com/vaadin/client/debug/internal/ProfilerSection.java index aa40e8ff17..91f626b9a5 100644 --- a/client/src/com/vaadin/client/debug/internal/ProfilerSection.java +++ b/client/src/com/vaadin/client/debug/internal/ProfilerSection.java @@ -71,6 +71,9 @@ public class ProfilerSection implements Section { private final LinkedHashMap<String, Node> children = new LinkedHashMap<String, Node>(); private double time = 0; private int count = 0; + private double enterTime = 0; + private double minTime = 1000000000; + private double maxTime = 0; /** * Create a new node with the given name. @@ -96,17 +99,17 @@ public class ProfilerSection implements Section { * * @param name * the name of the child - * @param time + * @param timestamp * the timestamp for when the node is entered * @return the child node object */ - public Node enterChild(String name, double time) { + public Node enterChild(String name, double timestamp) { Node child = children.get(name); if (child == null) { child = new Node(name); children.put(name, child); } - child.time -= time; + child.enterTime = timestamp; child.count++; return child; } @@ -122,6 +125,26 @@ public class ProfilerSection implements Section { } /** + * Gets the minimum time spent for one invocation of this node, + * including time spent in sub nodes + * + * @return the time spent for the fastest invocation, in milliseconds + */ + public double getMinTimeSpent() { + return minTime; + } + + /** + * Gets the maximum time spent for one invocation of this node, + * including time spent in sub nodes + * + * @return the time spent for the slowest invocation, in milliseconds + */ + public double getMaxTimeSpent() { + return maxTime; + } + + /** * Gets the number of times this node has been entered * * @return the number of times the node has been entered @@ -180,7 +203,11 @@ public class ProfilerSection implements Section { + getCount() + " times (" + roundToSignificantFigures(getTimeSpent() / getCount()) - + " ms per time)."; + + " ms per time, min " + + roundToSignificantFigures(getMinTimeSpent()) + + " ms, max " + + roundToSignificantFigures(getMaxTimeSpent()) + + " ms)."; } if (!children.isEmpty()) { double ownTime = getOwnTime(); @@ -221,6 +248,10 @@ public class ProfilerSection implements Section { totalNode.time += getOwnTime(); totalNode.count += getCount(); + totalNode.minTime = Math.min(totalNode.minTime, + getMinTimeSpent()); + totalNode.maxTime = Math.max(totalNode.maxTime, + getMaxTimeSpent()); } for (Node node : children.values()) { node.sumUpTotals(totals); @@ -228,11 +259,18 @@ public class ProfilerSection implements Section { } /** - * @since - * @param time + * @param timestamp */ - public void addTime(double time) { - this.time += time; + public void leave(double timestamp) { + double elapsed = (timestamp - enterTime); + time += elapsed; + enterTime = 0; + if (elapsed < minTime) { + minTime = elapsed; + } + if (elapsed > maxTime) { + maxTime = elapsed; + } } } |