Class 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
    • Constructor Detail

      • Profiler

        public Profiler()
    • Method Detail

      • 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.
        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 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 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