Java Performance Testing [duplicate]

More
1 month 3 weeks ago - 1 month 3 weeks ago #158100 by SandeepKommineni
SandeepKommineni created the topic: Java Performance Testing [duplicate]
I want to do some timing tests on a Java application.

This is what I am currently doing:

long startTime = System.currentTimeMillis();

doSomething();

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 month 3 weeks ago by DenisChenu. Reason: Don't spam : url removed

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now