Package com.vaadin.client
Class Profiler
java.lang.Object
com.vaadin.client.Profiler
- Direct Known Subclasses:
Profiler.EnabledProfiler
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:
- 1.0
- Author:
- Vaadin Ltd
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classEnables the profiling via deferred binding.static classA hierarchical representation of the time spent running a named block of code.static interfaceProvides access to data from theProfiler. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidEnters a named block.static doubleReturns time relative to the particular page load time.static StringgetRelativeTimeString(double reference) Returns a string, suitable for output to the user, containing the number of milliseconds which have elapsed since the given reference time.static voidInitializes the profiler.static booleanChecks whether the profiling gathering is enabled.protected booleanOverridden inProfiler.EnabledProfilerto makeisEnabled()return true if GWT.create returns that class.static voidLeaves a named block.static voidOutputs the time passed since various events recorded in performance.timing if supported by the browser.static voidOutputs the gathered profiling data to the debug console.static voidreset()Resets the collected profiler data.static voidsetProfilerResultConsumer(Profiler.ProfilerResultConsumer profilerResultConsumer) Sets the profiler result consumer that is used to output the profiler data to the user.
-
Constructor Details
-
Profiler
public Profiler()
-
-
Method Details
-
isEnabled
public static boolean isEnabled()Checks whether the profiling gathering is enabled.- Returns:
trueif the profiling is enabled, elsefalse
-
enter
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
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.- Returns:
- the relative time in milliseconds
-
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.
-
logTimings
public static void logTimings()Outputs the gathered profiling data to the debug console. -
isImplEnabled
protected boolean isImplEnabled()Overridden inProfiler.EnabledProfilerto makeisEnabled()return true if GWT.create returns that class.- Returns:
trueif the profiling is enabled, elsefalse
-
logBootstrapTimings
public static void logBootstrapTimings()Outputs the time passed since various events recorded 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
-
getRelativeTimeString
Returns a string, suitable for output to the user, containing the number of milliseconds which have elapsed since the given reference time.- Parameters:
reference- the reference time, as returned bygetRelativeTimeMillis()- Returns:
- a string containing the number of ms elapsed since the reference time
-