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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
public class loadestim {
public static long tempsm;
public static void main (String [] args) throws InterruptedException{
chargeur charg1=new chargeur();
charg1.start();
//chargeur charg2=new chargeur();
// charg2.start();
Estimation estimation= new Estimation() ;
estimation.start() ;
//chargeur charg4=new chargeur();
// charg4.start();
// chargeur charg3=new chargeur();
// charg3.start();
}
static class Estimation extends Thread {
long temps;
long t1;long t2;
long tot=0;
public void run(){
int nbr=120;
t1=System.nanoTime();
for ( int i=0; i<nbr;i++)
yield();
t2=System.nanoTime();
tot=(t2-t1)/1000000;
tempsm=tot/nbr;
System.out.println("load="+tempsm);
}
}
static class chargeur extends Thread {
int tab1[][];
int tab2[][];
int tab3[][];
int pr=0;
int l;
int p=2;
public void run(){
l=450;
tab1=new int[l][l];
tab2=new int[l][l];
tab3=new int[l][l];
long t0=System.nanoTime();
System.out.println("t0:"+t0);
for ( int i=0 ; i<l; i++){
for ( int j=0 ; j<l; j++){
tab1[i][j]=i*5 ;
tab2[i][j]=i*j ;
}}
for ( int j=0 ; j<l; j++){
for ( int k=0 ; k<l; k++){
for (int i=0;i<l;i++){
pr=pr+tab1[k][i]*tab2[i][j];
tab3[k][j]=pr;
}}}System.out.println("ok");
long t01=System.nanoTime();
System.out.println("t01:"+t01);
long ecart=(t01-t0)/1000000;System.out.println("ecart: "+ecart);
}
}
} |
Partager