I have a simple java program and I want to know the time difference between some sets of operations. Details are not important for this question, but let's look at the following scenario.
long beginTime = System.currentTimeMillis();
When the code runs on the machine, how reliable is the difference?
Suppose a processor starts to execute some instructions from my code, and then gives context to another process that has been running for some time, and then returns to execute the instructions associated with this java process.
So, the time difference should depend on the current state of my machine, i.e. on how many processes are running, etc.? So, during profiling, which is required to perform some operations, is this mechanism unreliable?
Sumeet khullar
source share