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:
1.0
Author:
Vaadin Ltd
  • Constructor Details

    • Profiler

      public Profiler()
  • Method Details

    • isEnabled

      public static boolean isEnabled()
      Checks whether the profiling gathering is enabled.
      Returns:
      true if the profiling is enabled, else false
    • enter

      public static void enter(String name)
      Enters a named block. There should always be a matching invocation of leave(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 of enter(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 in Profiler.EnabledProfiler to make isEnabled() return true if GWT.create returns that class.
      Returns:
      true if the profiling is enabled, else false
    • 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

      public static String getRelativeTimeString(double reference)
      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 by getRelativeTimeMillis()
      Returns:
      a string containing the number of ms elapsed since the reference time