To write a good comparations test test you have to run it several thousands (millions) times. It will level (in most cases) other programs' influence.
But if a JVM can influence on the results. For example:
First solution is:
final StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(getStrOne());
stringBuilder.append(getStrTwo());
final String result1 = stringBuilder.toString();
And second is:
final String result2 = getStrOne() + getStrTwo();
I do not know which one is better because JVM can influence on the results. How to know which one is better?
UPDATE: I don't mean exactly that appending comporation test. I'm asking about such a hard to test situation.