I want to test my code execution speed, my code :
public static String foo () {
final long startTime = System.currentTimeMillis ();
try {
// my code here
long final endtime = System.currentTimeMillis ();
System.out.println ("Total execution time:" + (endtime - startTime));
return msg;
} Catch (GeneralSecurityException e) {
return "ERROR";
}
}
but after execute this code multiple times (repeat test), I find the difference between total execution of same code. I assume it is because the systems loaded with background process. Is there a better way to do this?
Aucun commentaire:
Enregistrer un commentaire