Comment mesurer le coût en temps de l'exécution d'un programme Java? Comment estimer le coût en temps de mon programme. (Le programme est en cours d'exécution dans Eclipse)Comment mesurer le coût en temps?
code:
import java.util.Scanner;
public class S1_4 {
public static void main(String[] args) {
int i,j,k=1;
int[] table = new int[1000001];
for(i = 2;i<1000000;i++)
{
if(table[i]==0)
{
for(j=1;i*j<999999;j++)
table[i*j]=k;
k++;
}
}
int a;
Scanner cin = new Scanner(System.in);
while(cin.hasNext()) {
a = cin.nextInt();
System.out.println(table[a]);
}
cin.close();
}
}
Avez-vous vu: http://stackoverflow.com/questions/504103/how-do-i-write-a-correct-micro-benchmark-in-java? – harpun
En fait, il y a une approche AOP (aspectj, par exemple) si vous ne voulez pas changer le code existant. –