I'm using ASM java byte code instrumentation and my goal is to measure the time in each access to a variable.
** measure time and log **
** variable access **
I'm looking for a resolution of microseconds. It should be accurate and therefore "cheap" enough (meaning that I don't want a function or a library that will take 10 ms to get the time).
I've tried System.NanoTime()
(too much, and costly) and Calendar
(too loose), but I'm looking for a better alternative.
System.nanotime()
is a native method call, if that is too costly for you , then you probably wont be able to find something suitable to your needs in java.
I dont think System.nanotime()
will ever take 10ms (unless you specifically do something just to slow it down) to execute ever as well.
And finally, I am not sure if micro seconds will be precise enough for property access times, nanoseconds may be more useful.