Package com.vaadin.client
Class Profiler
- java.lang.Object
-
- com.vaadin.client.Profiler
-
- Direct Known Subclasses:
Profiler.EnabledProfiler
public class Profiler extends Object
Lightweight profiling tool that can be used to collect profiling data with zero overhead unless enabled. To enable profiling, add<set-property name="vaadin.profiler" value="true" />
to your .gwt.xml file.- Since:
- 7.0.0
- Author:
- Vaadin Ltd
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Profiler.EnabledProfiler
Class to include using deferred binding to enable the profiling.static class
Profiler.Node
A hierarchical representation of the time spent running a named block of code.static interface
Profiler.ProfilerResultConsumer
Interface for getting data from theProfiler
.
-
Constructor Summary
Constructors Constructor Description Profiler()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
enter(String name)
Enters a named block.static double
getRelativeTimeMillis()
Returns time relative to the particular page load time.static void
initialize()
Initializes the profiler.static boolean
isEnabled()
Checks whether the profiling gathering is enabled.protected boolean
isImplEnabled()
Overridden inProfiler.EnabledProfiler
to makeisEnabled()
return true if GWT.create returns that class.static void
leave(String name)
Leaves a named block.static void
logBootstrapTimings()
Outputs the time passed since various events recored in performance.timing if supported by the browser.static void
logTimings()
Outputs the gathered profiling data to the debug console.static void
reset()
Resets the collected profiler data.static void
setProfilerResultConsumer(Profiler.ProfilerResultConsumer profilerResultConsumer)
Sets the profiler result consumer that is used to output the profiler data to the user.
-
-
-
Method Detail
-
isEnabled
public static boolean isEnabled()
Checks whether the profiling gathering is enabled.- Returns:
true
if the profiling is enabled, elsefalse
-
enter
public static void enter(String name)
Enters a named block. There should always be a matching invocation ofleave(String)
when leaving the block. Calls to this method will be removed by the compiler unless profiling is enabled.- Parameters:
name
- the name of the entered block
-
leave
public static void leave(String name)
Leaves a named block. There should always be a matching invocation ofenter(String)
when entering the block. Calls to this method will be removed by the compiler unless profiling is enabled.- Parameters:
name
- the name of the left block
-
getRelativeTimeMillis
public static double getRelativeTimeMillis()
Returns time relative to the particular page load time. The value should not be used directly but rather difference between two values returned by this method should be used to compare measurements.- Since:
- 7.6
-
reset
public static void reset()
Resets the collected profiler data. Calls to this method will be removed by the compiler unless profiling is enabled.
-
initialize
public static void initialize()
Initializes the profiler. This should be done before calling any other function in this class. Failing to do so might cause undesired behavior. This method has no side effects if the initialization has already been done.Please note that this method should be called even if the profiler is not enabled because it will then remove a logger function that might have been included in the HTML page and that would leak memory unless removed.
- Since:
- 7.0.2
-
logTimings
public static void logTimings()
Outputs the gathered profiling data to the debug console.
-
isImplEnabled
protected boolean isImplEnabled()
Overridden inProfiler.EnabledProfiler
to makeisEnabled()
return true if GWT.create returns that class.- Returns:
true
if the profiling is enabled, elsefalse
-
logBootstrapTimings
public static void logBootstrapTimings()
Outputs the time passed since various events recored in performance.timing if supported by the browser.
-
setProfilerResultConsumer
public static void setProfilerResultConsumer(Profiler.ProfilerResultConsumer profilerResultConsumer)
Sets the profiler result consumer that is used to output the profiler data to the user.Warning! This is internal API and should not be used by applications or add-ons.
- Parameters:
profilerResultConsumer
- the consumer that gets profiler data- Since:
- 7.1.4
-
-