• Icon: Improvement Improvement
    • Resolution: Won't Fix
    • Icon: Major Major
    • timestamper-plugin
    • None

      Add the ability for nano seconds precision.

      Since "SimpleDateFormat" is not able to do this, may provide a switch to append the value of System.nanoTime() to the resulting time stamp? Extend to allow N formatting?

          [JENKINS-21171] Nano seconds precision

          Just as an example:

           
          import java.util.Date;
          import java.text.SimpleDateFormat;
          String result1 = new SimpleDateFormat("HH:mm:ss.SSSS.").format(new java.util.Date()) + System.nanoTime();
          String result2 = new SimpleDateFormat("HH:mm:ss.SSSS.").format(new java.util.Date()) + System.nanoTime();
          
          printf(result1 + '\n' + result2 + '\n' + System.nanoTime())
          

          Pedro Algarvio added a comment - Just as an example: import java.util.Date; import java.text.SimpleDateFormat; String result1 = new SimpleDateFormat( "HH:mm:ss.SSSS." ).format( new java.util.Date()) + System .nanoTime(); String result2 = new SimpleDateFormat( "HH:mm:ss.SSSS." ).format( new java.util.Date()) + System .nanoTime(); printf(result1 + '\n' + result2 + '\n' + System .nanoTime())

          Removed from the description:

          In the end, I'd like to make anchor links on the timestamped output and milliseconds is not precise enough for this.

          I've raised a new issue for this: JENKINS-21208

          Steven G Brown added a comment - Removed from the description: In the end, I'd like to make anchor links on the timestamped output and milliseconds is not precise enough for this. I've raised a new issue for this: JENKINS-21208

          I'm not convinced that nanoseconds precision is a good thing.

          It cannot be used for the "system clock time", because System.nanoTime() returns the number of nanoseconds since some fixed but arbitrary origin time (quoting the Javadoc). So there is no way to combine it with the number of milliseconds returned by System.currentTimeMillis() or new Date().

          It could be used for the "elapsed time", but I can't think why anyone would want this level of precision unless they are trying to use the Timestamper plugin for micro-benchmarking. And it is poorly suited for micro-benchmarking; the timings would be inaccurate due to the other work done by Jenkins between measurements.

          I understand that you wanted to include the nanoseconds for use in anchor names, but I think this can be done in other ways. I've put some ideas into JENKINS-21208.

          Steven G Brown added a comment - I'm not convinced that nanoseconds precision is a good thing. It cannot be used for the "system clock time", because System.nanoTime() returns the number of nanoseconds since some fixed but arbitrary origin time (quoting the Javadoc). So there is no way to combine it with the number of milliseconds returned by System.currentTimeMillis() or new Date() . It could be used for the "elapsed time", but I can't think why anyone would want this level of precision unless they are trying to use the Timestamper plugin for micro-benchmarking. And it is poorly suited for micro-benchmarking; the timings would be inaccurate due to the other work done by Jenkins between measurements. I understand that you wanted to include the nanoseconds for use in anchor names, but I think this can be done in other ways. I've put some ideas into JENKINS-21208 .

            stevengbrown Steven G Brown
            s0undt3ch Pedro Algarvio
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: