Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-17312

Additional option for showing elapsed time per line in the execution log

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • timestamper-plugin
    • None

      The suggestions is to have an additional option for showing the delta in the logged time from one line to the next, e.g. for a log that would look like this today:

      0:00:00.0  Job start
      0:00:00.0  First step takes 1.1 seconds
      0:00:01.1  Second step takes 12.4 seconds
      0:00:13.5  Third step takes 5.0 seconds
      0:00:18.5  Job done
      

      It would look like this with the 'elapsed' option:

      0:00:00.0  Job start
      0:00:01.1  First step takes 1.1 seconds
      0:00:12.4  Second step takes 12.4 seconds
      0:00:05.0  Third step takes 5.0 seconds
      0:00:18.5  Job done
      

          [JENKINS-17312] Additional option for showing elapsed time per line in the execution log

          Marc Günther added a comment -

          In your example, why does the last line show the absolute time difference again? Shouldn't that also be relative to the previous line, i.e. 0:00:00.0 Job done?

          Also, I would have expected, that the delta shows the time from the previous line to the current, and not from the current to the next. E.g. like this:

          0:00:00.0  Job start
          0:00:00.0  First step takes 1.1 seconds
          0:00:01.1  Second step takes 12.4 seconds
          0:00:12.4  Third step takes 5.0 seconds
          0:00:05.0  Job done
          

          I don't know why, but this feels more natural to me.

          Marc Günther added a comment - In your example, why does the last line show the absolute time difference again? Shouldn't that also be relative to the previous line, i.e. 0:00:00.0 Job done ? Also, I would have expected, that the delta shows the time from the previous line to the current, and not from the current to the next. E.g. like this: 0:00:00.0 Job start 0:00:00.0 First step takes 1.1 seconds 0:00:01.1 Second step takes 12.4 seconds 0:00:12.4 Third step takes 5.0 seconds 0:00:05.0 Job done I don't know why, but this feels more natural to me.

          Rob Fagen added a comment -

          Marc,

          The intention of the request is to be able to easily associate how long an action takes with the description of the action. With your example, you have to shift every timestamp backwards by a line to see what it was that took that long.

          Maybe this expresses the intent more clearly:

                       Task Time   Elapsed Time
          Job start -- 0:00:00.0   0:00:00.0
          Task 1    -- 0:00:01.1   0:00:01.1
          Task 2    -- 0:00:12.4   0:00:13.5
          Task 3    -- 0:00:05.0   0:00:18.5
          Job end   -- 0:00:00.0   0:00:18.5
          

          One of my goals is to be able to sort on the per-task time in order to find the fattest targets for optimization (or to find stuff that's taking far too long because of timeouts/failures/networks slowdowns/etc.)

          Rob Fagen added a comment - Marc, The intention of the request is to be able to easily associate how long an action takes with the description of the action. With your example, you have to shift every timestamp backwards by a line to see what it was that took that long. Maybe this expresses the intent more clearly: Task Time Elapsed Time Job start -- 0:00:00.0 0:00:00.0 Task 1 -- 0:00:01.1 0:00:01.1 Task 2 -- 0:00:12.4 0:00:13.5 Task 3 -- 0:00:05.0 0:00:18.5 Job end -- 0:00:00.0 0:00:18.5 One of my goals is to be able to sort on the per-task time in order to find the fattest targets for optimization (or to find stuff that's taking far too long because of timeouts/failures/networks slowdowns/etc.)

          Steven G Brown added a comment - - edited

          I'm OK with this feature being added.

          But if your aim is to parse the data with a script, I suggest adding an argument to the /timestamps URL for that.

          Steven G Brown added a comment - - edited I'm OK with this feature being added. But if your aim is to parse the data with a script, I suggest adding an argument to the /timestamps URL for that.

          Marc Günther added a comment -

          Hi Rob,

          I understand your intention, I had the same idea when I first saw those new radio buttons. My comment was just about which output format feels more natural.

          Lets say I have this script:

          echo "Building software"
          sleep 300
          echo "Building software finished, uploading to Nexus"
          sleep 20
          echo "Upload finished"
          

          I would expect this output:

          0:00:00 Building software
          0:05:00 Building software finished, uploading to Nexus
          0:00:20 Upload finished
          

          I guess because this looks more similar to the other output modes.

          With your version:

          0:05:00 Building software
          0:00:20 Building software finished, uploading to Nexus
          0:00:00 Upload finished
          

          the Console couldn't output the first line immediately, but would have to wait the whole 5mins. Or the output would have to be non linear, i.e. print the echo first, and later prepend the timestamp in the front. Both feel not very desireable.

          Your version might be easier to parse, though. It all depends on what and when you output in your echo's, I guess

          Marc Günther added a comment - Hi Rob, I understand your intention, I had the same idea when I first saw those new radio buttons. My comment was just about which output format feels more natural. Lets say I have this script: echo "Building software" sleep 300 echo "Building software finished, uploading to Nexus" sleep 20 echo "Upload finished" I would expect this output: 0:00:00 Building software 0:05:00 Building software finished, uploading to Nexus 0:00:20 Upload finished I guess because this looks more similar to the other output modes. With your version: 0:05:00 Building software 0:00:20 Building software finished, uploading to Nexus 0:00:00 Upload finished the Console couldn't output the first line immediately, but would have to wait the whole 5mins. Or the output would have to be non linear, i.e. print the echo first, and later prepend the timestamp in the front. Both feel not very desireable. Your version might be easier to parse, though. It all depends on what and when you output in your echo's, I guess

          From a user perspective, I think it definitely makes more sense to make the time a line has taken to show up in the gutter of the same line, i.e. Rob's version. This way long-running "hotspots" can be easily discovered.

          Like Marc says, for that to work in a nice visual way one would need to show the text of a line first, and then later add the elapsed time to that line that has already been printed. I don't know if the Jenkins API allows to do that at all. Maybe it would work for the static display of the console output, but I'm unsure about the dynamic display of the console output while the build is still running.

          Does anyone know if implementing it this way is even possible?

          Sebastian Schuberth added a comment - From a user perspective, I think it definitely makes more sense to make the time a line has taken to show up in the gutter of the same line, i.e. Rob's version. This way long-running "hotspots" can be easily discovered. Like Marc says, for that to work in a nice visual way one would need to show the text of a line first, and then later add the elapsed time to that line that has already been printed. I don't know if the Jenkins API allows to do that at all. Maybe it would work for the static display of the console output, but I'm unsure about the dynamic display of the console output while the build is still running. Does anyone know if implementing it this way is even possible?

          Yes, I believe it is possible to implement this in the plugin, even if the build is still running. As each line is written to the page, the TimestampFormatter.markup Java method could add an invisible HTML element containing the current time. Then a Javascript function could read these elements, work out the elapsed times, and change the console lines already displayed on the page. But if this turns out to be difficult, Marc's version would still be very useful!

          Steven G Brown added a comment - Yes, I believe it is possible to implement this in the plugin, even if the build is still running. As each line is written to the page, the TimestampFormatter.markup Java method could add an invisible HTML element containing the current time. Then a Javascript function could read these elements, work out the elapsed times, and change the console lines already displayed on the page. But if this turns out to be difficult, Marc's version would still be very useful!

          Daniel Beck added a comment - - edited

          Wouldn't the proposed time output format look really weird if the output looks like this?

          Extracting foo…
          Done!
          Extracting bar…
          Done!

          Maybe both options should be implemented as two different modes, 'Duration on line before', and 'Duration on line after'. This way, any user could choose the preferred output format based on how the logging works in a specific job.

          Daniel Beck added a comment - - edited Wouldn't the proposed time output format look really weird if the output looks like this? Extracting foo… Done! Extracting bar… Done! Maybe both options should be implemented as two different modes, 'Duration on line before', and 'Duration on line after'. This way, any user could choose the preferred output format based on how the logging works in a specific job.

          I'll be glad to see elapsed time starting from zero.
          This will help us track the steps when a video is recorded.

          0:00:00.0 Job start
          0:00:00.0 First step takes
          0:00:01.1 Second step takes
          0:00:13.5 Third step takes
          0:00:18.5 Done

          zdravko branzov added a comment - I'll be glad to see elapsed time starting from zero. This will help us track the steps when a video is recorded. 0:00:00.0 Job start 0:00:00.0 First step takes 0:00:01.1 Second step takes 0:00:13.5 Third step takes 0:00:18.5 Done

            Unassigned Unassigned
            rfagen Rob Fagen
            Votes:
            4 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated: