If I am designing a test on sorting algorithm can I do this way to avoid JVM warmup ?
Some pedantry first. You should not avoid JVM warmup. It needs to happen. What you are trying to do is to prevent the JVM warmup from distorting your benchmark results.
To answer your question, the approach is roughly right, but it is very difficult to predict how many times you need to do the test in the initial loop. It is likely to depend on the test code, on the JVM version and on JVM tuning parameter ... and probably other things besides.
What I normally do is to just print the raw timings, filter out the initial "warmup" iterations that appear to have anomalous timing values "by eye", and then calculate the averages by hand. It is clunky, but it gives me some confidence that I've accounted for warmup and other possible sources of anomalies.