Java Performance Testing [duplicate]

1 year 5 months ago - 1 year 5 months ago #158100 by SandeepKommineni
I want to do some timing tests on a Java application.

This is what I am currently doing:

long startTime = System.currentTimeMillis();


long finishTime = System.currentTimeMillis();

System.out.println("That took: "+(finishTime-startTime)+ " ms");
Is there anything "wrong" with performance testing like this? What is a better way?

Does anyone ever use stopwatch benchmarking, or should a
Don't spam : url removed
Performance Tuning tool always be used? Are there any good free tools available for Java? What tools do you use?

To clarify my concerns, stopwatch benchmarking is subject to error due to operating system scheduling. On a given run of your program the OS might schedule another process (or several) in the middle of the function you're timing. In Java things are even a little bit worse if you're trying to time a threaded application, as the JVM scheduler throws even a little bit more randomness into the mix.

How do you address operating system scheduling when benchmarking?
Last edit: 1 year 5 months ago by DenisChenu. Reason: Don't spam : url removed

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!