Here I have this method
@Override public double calculateMiddleVarOfAxisZ(double axisZ) { long startTime = System.currentTimeMillis(); long current = System.currentTimeMillis(); countAxisZTimes++; countAxisZSum += axisZ; mapAxisZ.put(current, axisZ); if (mapAxisZ.size() == 1) { return axisZ; } Iterator iterator = mapAxisZ.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry<Long, Double> point = (Map.Entry) iterator.next(); long pointTime = point.getKey(); long difference = current - pointTime; if (difference > getTime(mapAxisZ)) { double val = point.getValue(); countAxisZTimes--; countAxisZSum -= val; iterator.remove(); } } double result = countAxisZSum / countAxisZTimes; Logger.logGeneral(String.valueOf(result) + " size : " + mapAxisZ.size()); long finishTime = System.currentTimeMillis(); Logger.logGeneral("Start : " + startTime + " finish : " + finishTime + " Time diff Z: " + ( finishTime - startTime)); return result; } I need to calculate the exact execution time. In my example, I take the time when the method started execution and when it finishes and find the difference
In the last line I display the log
Start : 1481102600075 finish : 1481102600075 Time diff Z: 0 As far as I understand, the minimum time unit available from this number is 1481102600075 this is a thousandth of a second (millisecond) 10 to 3 degrees. Since 1000 is a second.
So how in my case can be calculated more accurately? Maybe microseconds or nano ...