Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-40521

Introduce new API for automated execution time measurement

    Details

    • Type: Feature Request
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Core Infrastructure
    • Labels:
      None

      Description

      In many places in the portal we use the following pattern for tracking the execution time of certain methods or code blocks.

      public void someMethod() {
          StopWatch stopWatch = null;
      
          if (_log.isDebugEnabled()) {
              stopWatch = new StopWatch();
      
              stopWatch.start();
          }
      
          // Some processing is here
      
          if (stopWatch != null) {
              stopWatch.stop();
      
              _log.debug(
                  "doAddPermissions() took " + stopWatch.getTime() + " ms");
          }
      }
      

      The problem here is that we do not follow the DRY (Don't Repeat Yourself) principle.

      We could achieve the same if we had an API like that:

      public void someMethod() {
          StopWatchUtil.start();
      
          // Some processing is here
      
          StopWatchUtil.getTime();
      
          StopWatchUtil.stop();
      }
      

      The new API should take care of monitoring the log level of the current caller
      and handling the life-cycle of stop watches automatically.

        Attachments

          Activity

            People

            • Assignee:
              support-lep@liferay.com SE Support
              Reporter:
              laszlo.csontos Laszlo Csontos (Inactive)
            • Votes:
              3 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:

                Packages

                Version Package