Menu

FirstAccess and LastAccess dates invalid when using nano

Help
2021-10-13
2021-10-24
  • ChristopheD

    ChristopheD - 2021-10-13

    Hi,

    When using nanoseconds through MonitorFactory.startNano(), the values for firstAccess and lastAccess are set to 1/1/1970. Am I doing something wrong ?

    Regards,
    Christophe

     
  • Steve Souza

    Steve Souza - 2021-10-15

    Did you stop the monitor? Those values are set when you stop the monitor only. Also, just to confirm you called the startNano method with a lable. The label is required: MonitorFactory.startNano("label")

    Monitor mon = MonitorFactory.startNano();
    System.out.println(mon.stop());
    

    Please post your full code and what is printed...

     

    Last edit: Steve Souza 2021-10-15
  • ChristopheD

    ChristopheD - 2021-10-15

    Hi Steve,

    yes I am stopping the monitor. Here is the result of the simple code execution :

    Monitor mon = MonitorFactory.startNano("test");
    System.out.println(mon.stop());
    
    JAMon Label=test, Units=ns., InstanceName=local: (LastValue=6858.0, Hits=1.0, Avg=6858.0, Total=6858.0, Min=6858.0, Max=6858.0, Active=0.0, Avg Active=1.0, Max Active=1.0, First Access=Mon Jan 05 00:20:57 UTC 1970, Last Access=Mon Jan 05 00:20:57 UTC 1970)
    

    When using milliseconds :

    Monitor mon = MonitorFactory.start("test - ms");
    System.out.println(mon.stop());
    
    JAMon Label=test - ms, Units=ms., InstanceName=local: (LastValue=0.0, Hits=1.0, Avg=0.0, Total=0.0, Min=0.0, Max=0.0, Active=0.0, Avg Active=1.0, Max Active=1.0, First Access=Fri Oct 15 08:29:41 UTC 2021, Last Access=Fri Oct 15 08:29:41 UTC 2021)
    

    Running with java 8 on a Max OSX.

    Regards,
    Christophe

     
  • Steve Souza

    Steve Souza - 2021-10-23

    You are right there is a problem here. How urgent is the problem for you? A short term work around may be to directly set the values that are not being updated automatically.

     
    • ChristopheD

      ChristopheD - 2021-10-24

      Hi Steve,

      Not urgent for me. Thank you for the follow up.

      Regards,
      Christophe

      Le 23 oct. 2021 à 17:23, Steve Souza stevesouza@users.sourceforge.net a écrit :

      
      You are right there is a problem here. How urgent is the problem for you? A short term work around may be to directly set the values that are not being updated automatically.

      FirstAccess and LastAccess dates invalid when using nano

      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/jamonapi/discussion/334831/

      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

       
  • Steve Souza

    Steve Souza - 2021-10-24

    After looking into this nanotime has no relation to clock time (and in fact it can vary from jvm to jvm) and it is only useful when calculating the difference between 2 nanotimes (startTime-endTime). There is no useful meaning in nanotime unless you do a difference. This means clock time can not be calculated from nanotime.

    This is not true of millisecond times. They are based on clock time (since 1970).

    I am going to opt not to fix this as one wouldn't use nanotime timers unless the time you are measuring is very short. Calculating the clock time would require a call to get the milliseconds, so I am opting to document firstAcccess and lastAccess are not supported when measuring nanoTime.

    Here is more information on nanoTime - https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/System.html#nanoTime()

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.