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")
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
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.
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
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")
Please post your full code and what is printed...
Last edit: Steve Souza 2021-10-15
Hi Steve,
yes I am stopping the monitor. Here is the result of the simple code execution :
When using milliseconds :
Running with java 8 on a Max OSX.
Regards,
Christophe
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.
Hi Steve,
Not urgent for me. Thank you for the follow up.
Regards,
Christophe
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()