1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
import chronometre.Chrono;
public class Boucle {
public static void main(String[] args) {
Chrono chrono = new Chrono() ;
int iMax = 3 ;
long lMax = 10000000000l ;
//type primitif
byte refTP = (byte)0 ;
//affectation interne
for(int i=0 ; i<iMax ; i++) {
chrono.start();
for(long l=0 ; l<lMax ; l++) {
byte test1 = refTP ;
}
chrono.stop();
System.out.println("affectation interne, type primitif: "+chrono.getMilliSec()) ;
}
//affectation externe
byte test2 ;
for(int i=0 ; i<iMax ; i++) {
chrono.start();
for(long l=0 ; l<lMax ; l++) {
test2 = refTP ;
}
chrono.stop();
System.out.println("affectation externe, type primitif: "+chrono.getMilliSec()) ;
}
//objet
Byte refO = new Byte((byte)0) ;
//affectation interne
for(int i=0 ; i<iMax ; i++) {
chrono.start();
for(long l=0 ; l<lMax ; l++) {
Byte test3 = refO ;
}
chrono.stop();
System.out.println("affectation interne, objet: "+chrono.getMilliSec()) ;
}
//affectation externe
Byte test4 ;
for(int i=0 ; i<iMax ; i++) {
chrono.start();
for(long l=0 ; l<lMax ; l++) {
test4 = refO ;
}
chrono.stop();
System.out.println("affectation externe, objet: "+chrono.getMilliSec()) ;
}
}
} |
Partager