Measuring performance

  • Christian
    Participant
      3 years, 5 months ago #30145

      Hi all

      in some situations, it takes quite a long time to get the response from my server-side business object. To measure the execution time as starting point for a refactoring, I want to use performance.now() (https://developer.mozilla.org/de/docs/Web/API/Performance/now). However, in the server-side BO, “performance” is not known. How could I use the performance object? Is there another/better way to measure the performance?

      Thank you!

      Daniel
      Moderator
        Has successfully completed the online course Introduction
        Has successfully completed the online course Intermediate (200)
        Has successfully completed the online course Advanced (300)
        Has successfully completed the online course Basics (100)
      3 years, 5 months ago #30147
      Up
      0
      Down
      ::

      Hi Christian,

      you can use momentjs for this task:

      var oStart = moment();
      //perform logic e.g. connector calls
      var oEnd = moment();

      var iDuration = oEnd.diff(oStart); //difference between start and end in milliseconds
      output.duration = iDuration;

      For more information about the diff function of moment js please check the following page:
      https://momentjscom.readthedocs.io/en/latest/moment/04-displaying/07-difference/

      Best regards,
      Dan

      Christian
      Participant
        3 years, 5 months ago #30152
        Up
        0
        Down
        ::

        Hi Dan, thank you for the quick answer. I assumed that moment is rather a heavy weight JS object so I wanted to use a native one, but from a functionality perspective this works 🙂

      Viewing 3 posts - 1 through 3 (of 3 total)

      You must be logged in to reply to this topic.