Looking at the JMeter code, I found the section below interesting. So the main thread is the one that sleeps for NANOTHREAD_SLEEP milliseconds, and then when it wakes up, it asks for the time.
This value should remain as high as possible so as not to add too much overhead to the sample, but should remain as low as possible to ensure sufficient accuracy.
If you are not using nanothread, then all the time it is calculated using System.nanoTime (), and this may or may not give additional accuracy. As a rule, high accuracy counters are strongly affected by frequency changes (for example, due to energy-saving modes). My opinion is that you donโt have to worry about using System.nanoTime (), because you wonโt be able to repeat the test to the nanosecond level . Even a millisecond seems very difficult for this.
Why use a background thread to calculate time? I think this is because if a thread only measures time, you can set it to the current time at any time during execution. If you are not using a background thread, I think that the time is updated only at the sampling point. With the thread on, I think time is updated more often (assuming NANOTHREAD_SLEEP well considered). I did not write JMeter, but I think that this is the philosophy behind the temporary thread.
Is this useful? It can probably compress extra precision. However, JMeter is used to test web application performance , where repeatability is poor due to network latency, resource usage, etc. . Even if you measure nanoseconds, people will be more interested in seconds and milliseconds and that the test is repeated.
CODE:
private static class NanoOffset extends Thread { private static volatile long nanoOffset; static long getNanoOffset() { return nanoOffset; } @Override public void run() {
source share