Accueil > > > POWER MATH: TESTE DE VITESSE ENTIERS VS REELS , CLASS VS STRUCT
POWER MATH: TESTE DE VITESSE ENTIERS VS REELS , CLASS VS STRUCT
Information sur la source
Description
Souvent la question de la rapidité de traitement se pose et il faut faire des choix avant de commencer une application. Dans mon cas j'ai eu besoin de tester la vitesse de différents types de variables préalablement à la programmation d'une application temps réel en 4D. Je souhaitais également vérifier si l'emploi de struct ou class ne pénalisait pas les performances. test pour: Les entiers 8, 16, 32 et 64 bits. Les réels 32, 64 et 80 bits. I/O dans un tableau, global, local, class et struct.
Source
- //******************
- //*** POWER MATH ***
- //******************
-
- //Version 1.0
-
- //Developed with Dev C++
-
- //Programme d'evaluation de la vitesse de calcul
- //Pour differents types de variables
- //Affectation & operateurs
- //Boucle de 1 milliard
- //Test de vitesse autres fonctions
-
- //By Alain Galiani
- //Geek Star Wars 1983
- //Alias Dedalusman
- //nageondu@yahoo.fr
-
- //Start 29 12 2009
- //Finished 00 00 2012
- //Last updat 05 03 2010
-
- //History:
-
- /*
-
- Servira pour tester Geek Star Wars 1983
-
- 05 03 2010 test des tableaux global local class et struct
-
-
- */
-
- #include<iostream.h>
- #include<windows.h>
-
- //definition des types
-
- typedef unsigned char cop;
- typedef signed char co;
-
- typedef unsigned short m2op;
- typedef signed short m2o;
-
- typedef unsigned long lm4op;
- typedef signed long lm4o;
-
- typedef unsigned long long llm8op;
- typedef signed long long llm8o;
-
- typedef float flo4;
- typedef double flo8;
- typedef long double flo10;
-
- //*** class ***
-
- class class_objet_num
- {
- public:
-
- //constructeur et destructeur inline
- class_objet_num(){}
- ~class_objet_num(){}
-
- flo8 tab_sommets[1000];//x
- };
-
- class class_objet_4d
- {
- public:
-
- //constructeur et destructeur inline
- class_objet_4d(){}
- ~class_objet_4d(){}
-
- class_objet_num numerique;
- };
-
- //*** struct ***
-
- struct struct_objet_num
- {
- public:
- flo8 tab_sommets[1000];//x
- };
-
- class struct_objet_4d
- {
- public:
- struct_objet_num numerique;
- };
-
- flo8 global_tab[1000];
- flo8 gl1,gl2,gl3,gl4;
-
- int main()
- {
-
- flo8 local_tab[1000];
- flo8 lo1,lo2,lo3,lo4;
-
- class_objet_4d univers[10];//univers pour 10 objets 4D
- struct_objet_4d uni[10];//univers pour 10 objets 4D
-
- //definition du ptr univers
- class_objet_4d*ptr_univers;
- ptr_univers=&univers[0];
-
- //definition du ptr univers
- struct_objet_4d*ptr_uni;
- ptr_uni=&uni[0];
-
- char nom[256];
-
- //******************************************
- //*** Declaration de variables entieres ***
- //******************************************
-
- //variable -128 a 127
- co a1,a2,a3,a4,a5,a6,a7;
-
- //variable -32768 a 32767
- m2o b1,b2,b3,b4,b5,b6,b7;
-
- //variable -2147483648 a 2147483647
- lm4o c1,c2,c3,c4,c5,c6,c7;
-
- //variable -9223372036854775808 a 9223372036854775807
- llm8o d1,d2,d3,d4,d5,d6,d7;
-
- //*****************************************
- //*** Declaration de variables reelles ***
- //*****************************************
-
- //reel 32 bit
- flo4 e1,e2,e3,e4,e5,e6,e7;
-
- //reel 64 bit
- flo8 f1,f2,f3,f4,f5,f6,f7;
-
- //reel 80 bit
- flo10 g1,g2,g3,g4,g5,g6,g7;
-
- //variables divers
- lm4op nb,nbb;
- flo4 temcal;
- lm4o temdeb;
- flo4 tab_v[90][10];
-
- for(nb=1;nb<90;nb++)
- {
- for(nbb=1;nbb<10;nbb++)
- {
- tab_v[nb][nbb]=1234.56;
- }
- }
-
- cout<<"******************\n";
- cout<<"*** POWER MATH ***\n";
- cout<<"******************\n";
-
- //goto test;
- //test:
-
- tout:
-
- //***********************
- //*** VITESSE ENTIERS ***
- //***********************
-
- cout<<"\n*** ENTIERS ***\n\n";
-
- //teste de vitesse ************************************
- temdeb=GetTickCount();
- a2=45;
- a3=-100;
- for(nb=0;nb<1000000000;nb++)
- {
- a1=a2+a3;
- }
- temcal=(float)(GetTickCount()-temdeb)/1000.;
- cout<<"a1=a2+a3 "<<int(a1)<<" entier 8 bit 1000000000 boucles = "<<temcal<<"\n";
- tab_v[1][1]=temcal;
-
- //teste de vitesse ************************************
- temdeb=GetTickCount();
- b2=21024;
- b3=-10270;
- for(nb=0;nb<1000000000;nb++)
- {
- b1=b2+b3;
- }
- temcal=(float)(GetTickCount()-temdeb)/1000.;
- cout<<"b1=b2+b3 "<<b1<<" entier 16 bit 1000000000 boucles = "<<temcal<<"\n";
- tab_v[1][2]=temcal;
-
- //teste de vitesse ************************************
- temdeb=GetTickCount();
- c2=2007483647;
- c3=-1588796587;
- for(nb=0;nb<1000000000;nb++)
- {
- c1=c2+c3;
- }
- temcal=(float)(GetTickCount()-temdeb)/1000.;
- cout<<"c1=c2+c3 "<<c1<<" entier 32 bit 1000000000 boucles = "<<temcal<<"\n";
- tab_v[1][3]=temcal;
-
- //teste de vitesse ************************************
- temdeb=GetTickCount();
- d2=8223372036854775808LL;
- d3=-1223372036854775807LL;
- for(nb=0;nb<1000000000;nb++)
- {
- d1=d2+d3;
- }
- temcal=(float)(GetTickCount()-temdeb)/1000.;
- cout<<"d1=d2+d3 "<<d1<<" entier 64 bit 1000000000 boucles = "<<temcal<<"\n";
- tab_v[1][4]=temcal;
-
- //teste de vitesse ************************************
- temdeb=GetTickCount();
- a2=35;
- a3=-3;
- for(nb=0;nb<1000000000;nb++)
- {
- a1=a2*a3;
- }
- temcal=(float)(GetTickCount()-temdeb)/1000.;
- cout<<"a1=a2*a3 "<<int(a1)<<" entier 8 bit 1000000000 boucles = "<<temcal<<"\n";
- tab_v[2][1]=temcal;
-
- //teste de vitesse ************************************
- temdeb=GetTickCount();
- b2=2102;
- b3=-11;
- for(nb=0;nb<1000000000;nb++)
- {
- b1=b2*b3;
- }
- temcal=(float)(GetTickCount()-temdeb)/1000.;
- cout<<"b1=b2*b3 "<<b1<<" entier 16 bit 1000000000 boucles = "<<temcal<<"\n";
- tab_v[2][2]=temcal;
-
- //teste de vitesse ************************************
- temdeb=GetTickCount();
- c2=2007483;
- c3=-658;
- for(nb=0;nb<1000000000;nb++)
- {
- c1=c2*c3;
- }
- temcal=(float)(GetTickCount()-temdeb)/1000.;
- cout<<"c1=c2*c3 "<<c1<<" entier 32 bit 1000000000 boucles = "<<temcal<<"\n";
- tab_v[2][3]=temcal;
-
- //teste de vitesse ************************************
- temdeb=GetTickCount();
- d2=12345678901234LL;
- d3=-12345LL;
- for(nb=0;nb<1000000000;nb++)
- {
- d1=d2*d3;
- }
- temcal=(float)(GetTickCount()-temdeb)/1000.;
- cout<<"d1=d2*d3 "<<d1<<" entier 64 bit 1000000000 boucles = "<<temcal<<"\n";
- tab_v[2][4]=temcal;
-
- //teste de vitesse ************************************
- temdeb=GetTickCount();
- a2=123;
- a3=-13;
- for(nb=0;nb<1000000000;nb++)
- {
- a1=a2/a3;
- }
- temcal=(float)(GetTickCount()-temdeb)/1000.;
- cout<<"a1=a2/a3 "<<int(a1)<<" entier 8 bit 1000000000 boucles = "<<temcal<<"\n";
- tab_v[3][1]=temcal;
-
- //teste de vitesse ************************************
- temdeb=GetTickCount();
- b2=21024;
- b3=-123;
- for(nb=0;nb<1000000000;nb++)
- {
- b1=b2/b3;
- }
- temcal=(float)(GetTickCount()-temdeb)/1000.;
- cout<<"b1=b2/b3 "<<b1<<" entier 16 bit 1000000000 boucles = "<<temcal<<"\n";
- tab_v[3][2]=temcal;
-
- //teste de vitesse ************************************
- temdeb=GetTickCount();
- c2=2007483647;
- c3=-15887;
- for(nb=0;nb<1000000000;nb++)
- {
- c1=c2/c3;
- }
- temcal=(float)(GetTickCount()-temdeb)/1000.;
- cout<<"c1=c2/c3 "<<c1<<" entier 32 bit 1000000000 boucles = "<<temcal<<"\n";
- tab_v[3][3]=temcal;
-
- //teste de vitesse ************************************
- temdeb=GetTickCount();
- d2=8223372036854775808LL;
- d3=-1223372036LL;
- for(nb=0;nb<1000000000;nb++)
- {
- d1=d2/d3;
- }
- temcal=(float)(GetTickCount()-temdeb)/1000.;
- cout<<"d1=d2/d3 "<<d1<<" entier 64 bit 1000000000 boucles = "<<temcal<<"\n";
- tab_v[3][4]=temcal;
-
- tab_v[4][1]=tab_v[1][1]+tab_v[2][1]+tab_v[3][1];
- tab_v[4][2]=tab_v[1][2]+tab_v[2][2]+tab_v[3][2];
- tab_v[4][3]=tab_v[1][3]+tab_v[2][3]+tab_v[3][3];
- tab_v[4][4]=tab_v[1][4]+tab_v[2][4]+tab_v[3][4];
-
- //teste de vitesse ************************************
- temdeb=GetTickCount();
- a2=123;
- b3=4;
- for(nb=0;nb<1000000000;nb++)
- {
- a1=a2>>b3;
- }
- temcal=(float)(GetTickCount()-temdeb)/1000.;
- cout<<"a1=a2>>b3 "<<int(a1)<<" entier 8 bit 1000000000 boucles = "<<temcal<<"\n";
- tab_v[5][1]=temcal;
-
- //teste de vitesse ************************************
- temdeb=GetTickCount();
- b2=-31123;
- b3=8;
- for(nb=0;nb<1000000000;nb++)
- {
- b1=b2>>b3;
- }
- temcal=(float)(GetTickCount()-temdeb)/1000.;
- cout<<"b1=b2>>b3 "<<b1<<" entier 16 bit 1000000000 boucles = "<<temcal<<"\n";
- tab_v[5][2]=temcal;
-
- //teste de vitesse ************************************
- temdeb=GetTickCount();
- c2=2147483640;
- b3=10;
- for(nb=0;nb<1000000000;nb++)
- {
- c1=c2>>b3;
- }
- temcal=(float)(GetTickCount()-temdeb)/1000.;
- cout<<"c1=c2>>b3 "<<c1<<" entier 32 bit 1000000000 boucles = "<<temcal<<"\n";
- tab_v[5][3]=temcal;
-
- //teste de vitesse ************************************
- temdeb=GetTickCount();
- d2=-8223372036854775808LL;
- b3=10;
- for(nb=0;nb<1000000000;nb++)
- {
- d1=d2>>b3;
- }
- temcal=(float)(GetTickCount()-temdeb)/1000.;
- cout<<"d1=d2>>b3 "<<d1<<" entier 64 bit 1000000000 boucles = "<<temcal<<"\n";
- tab_v[5][4]=temcal;
-
- tab_v[6][1]=tab_v[5][1]+tab_v[4][1];
- tab_v[6][2]=tab_v[5][2]+tab_v[4][2];
- tab_v[6][3]=tab_v[5][3]+tab_v[4][3];
- tab_v[6][4]=tab_v[5][4]+tab_v[4][4];
-
- reels:
-
- //*********************
- //*** VITESSE REELS ***
- //*********************
-
- cout<<"\n*** REELS ***\n\n";
-
- //teste de vitesse ************************************
- temdeb=GetTickCount();
- e2=12345.6789;
- e3=-9876.54321;
- for(nb=0;nb<1000000000;nb++)
- {
- e1=e2+e3;
- }
- temcal=(float)(GetTickCount()-temdeb)/1000.;
- cout<<"e1=e2+e3 "<<e1<<" reel 32 bit 1000000000 boucles = "<<temcal<<"\n";
- tab_v[11][1]=temcal;
-
- //teste de vitesse ************************************
- temdeb=GetTickCount();
- f2=123456789.1234567;
- f3=-9876543.7654321;
- for(nb=0;nb<1000000000;nb++)
- {
- f1=f2+f3;
- }
- temcal=(float)(GetTickCount()-temdeb)/1000.;
- cout<<"f1=f2+f3 "<<f1<<" reel 64 bit 1000000000 boucles = "<<temcal<<"\n";
- tab_v[11][2]=temcal;
-
- //teste de vitesse ************************************
- temdeb=GetTickCount();
- g2=1234567890123.123456789012;
- g3=-9876543210.987654321;
- for(nb=0;nb<1000000000;nb++)
- {
- g1=g2+g3;
- }
- temcal=(float)(GetTickCount()-temdeb)/1000.;
- cout<<"g1=g2+g3 "<<g1<<" reel 80 bit 1000000000 boucles = "<<temcal<<"\n";
- tab_v[11][3]=temcal;
-
- //teste de vitesse ************************************
- temdeb=GetTickCount();
- e2=12345.6789;
- e3=-98.54321;
- for(nb=0;nb<1000000000;nb++)
- {
- e1=e2*e3;
- }
- temcal=(float)(GetTickCount()-temdeb)/1000.;
- cout<<"e1=e2*e3 "<<e1<<" reel 32 bit 1000000000 boucles = "<<temcal<<"\n";
- tab_v[12][1]=temcal;
-
- //teste de vitesse ************************************
- temdeb=GetTickCount();
- f2=1234567.1234567;
- f3=-987.7654321;
- for(nb=0;nb<1000000000;nb++)
- {
- f1=f2*f3;
- }
- temcal=(float)(GetTickCount()-temdeb)/1000.;
- cout<<"f1=f2*f3 "<<f1<<" reel 64 bit 1000000000 boucles = "<<temcal<<"\n";
- tab_v[12][2]=temcal;
-
- //teste de vitesse ************************************
- temdeb=GetTickCount();
- g2=1234567123.123456789012;
- g3=-98765.987654321;
- for(nb=0;nb<1000000000;nb++)
- {
- g1=g2*g3;
- }
- temcal=(float)(GetTickCount()-temdeb)/1000.;
- cout<<"g1=g2*g3 "<<g1<<" reel 80 bit 1000000000 boucles = "<<temcal<<"\n";
- tab_v[12][3]=temcal;
-
- //teste de vitesse ************************************
- temdeb=GetTickCount();
- e2=12345.6789;
- e3=-98.54321;
- for(nb=0;nb<1000000000;nb++)
- {
- e1=e2/e3;
- }
- temcal=(float)(GetTickCount()-temdeb)/1000.;
- cout<<"e1=e2/e3 "<<e1<<" reel 32 bit 1000000000 boucles = "<<temcal<<"\n";
- tab_v[13][1]=temcal;
-
- //teste de vitesse ************************************
- temdeb=GetTickCount();
- f2=1234567.1234567;
- f3=-987.7654321;
- for(nb=0;nb<1000000000;nb++)
- {
- f1=f2/f3;
- }
- temcal=(float)(GetTickCount()-temdeb)/1000.;
- cout<<"f1=f2/f3 "<<f1<<" reel 64 bit 1000000000 boucles = "<<temcal<<"\n";
- tab_v[13][2]=temcal;
-
- //teste de vitesse ************************************
- temdeb=GetTickCount();
- g2=1234567123.123456789012;
- g3=-98765.987654321;
- for(nb=0;nb<1000000000;nb++)
- {
- g1=g2/g3;
- }
- temcal=(float)(GetTickCount()-temdeb)/1000.;
- cout<<"g1=g2/g3 "<<g1<<" reel 80 bit 1000000000 boucles = "<<temcal<<"\n";
- tab_v[13][3]=temcal;
-
- //test:
-
- tableaux:
-
- //******************************************************
- //*** VITESSE I/O TABLEAUX GLOBAL LOCAL CLASS STRUCT ***
- //******************************************************
-
- cout<<"\n*** VITESSE I/O TABLEAUX GLOBAL LOCAL CLASS STRUCT ***\n\n";
-
- //teste de vitesse ************************************
- temdeb=GetTickCount();
- gl1=123456789;
- for(nb=0;nb<1000000;nb++)
- {
- for(int nb2=0;nb2<1000;nb2++)
- {
- global_tab[nb2]=gl1;
- gl2=global_tab[nb2];
- }
- }
- temcal=(float)(GetTickCount()-temdeb)/1000.;
- cout<<"flo8 global_tab[1000] entree et sortie 1000000 boucles = "<<temcal<<"\n";
-
- //teste de vitesse ************************************
- temdeb=GetTickCount();
- lo1=123456789;
- for(nb=0;nb<1000000;nb++)
- {
- for(int nb2=0;nb2<1000;nb2++)
- {
- local_tab[nb2]=lo1;
- lo2=local_tab[nb2];
- }
- }
- temcal=(float)(GetTickCount()-temdeb)/1000.;
- cout<<"flo8 local_tab[1000] entree et sortie 1000000 boucles = "<<temcal<<"\n";
-
- //teste de vitesse ************************************
- temdeb=GetTickCount();
- lo1=123456789;
- for(nb=0;nb<1000000;nb++)
- {
- for(int nb2=0;nb2<1000;nb2++)
- {
- ptr_univers->numerique.tab_sommets[nb2]=lo1;
- lo2=ptr_univers->numerique.tab_sommets[nb2];
- }
- }
- temcal=(float)(GetTickCount()-temdeb)/1000.;
- cout<<"flo8 CLASS univers[0].numerique.tab_sommets[1000] I/O 1000000 bcl = "<<temcal<<"\n";
-
- //teste de vitesse ************************************
- temdeb=GetTickCount();
- lo1=123456789;
- for(nb=0;nb<1000000;nb++)
- {
- for(int nb2=0;nb2<1000;nb2++)
- {
- ptr_uni->numerique.tab_sommets[nb2]=lo1;
- lo2=ptr_uni->numerique.tab_sommets[nb2];
- }
- }
- temcal=(float)(GetTickCount()-temdeb)/1000.;
- cout<<"flo8 STRUCT uni[0].numerique.tab_sommets[1000] I/O 1000000 bcl = "<<temcal<<"\n";
-
- tab_v[14][1]=tab_v[11][1]+tab_v[12][1]+tab_v[13][1];
- tab_v[14][2]=tab_v[11][2]+tab_v[12][2]+tab_v[13][2];
- tab_v[14][3]=tab_v[11][3]+tab_v[12][3]+tab_v[13][3];
-
- //test:
-
- cout<<"\n\n\t\t*** TABLEAU ENTIERS ***\n\n";
- cout<<"\t\t8 bit\t16 bit\t32 bit\t64 bit\n\n";
- for(nb=1;nb<7;nb++)
- {
- if(nb==1)cout<<"\t+\t";
- if(nb==2)cout<<"\t*\t";
- if(nb==3)cout<<"\t\\\t";
- if(nb==4)cout<<"\n\tS_TOT\t";
- if(nb==5)cout<<"\n\t>>\t";
- if(nb==6)cout<<"\n\tTOTAL\t";
-
- for(nbb=1;nbb<5;nbb++)
- {
- cout<<tab_v[nb][nbb]<<"\t";
- }
- cout<<"\n";
- }
-
- cout<<"\n\n\t\t*** TABLEAU REELS ***\n\n";
- cout<<"\t\t32 bit\t64 bit\t80 bit\n\n";
- for(nb=11;nb<15;nb++)
- {
- if(nb==11)cout<<"\t+\t";
- if(nb==12)cout<<"\t*\t";
- if(nb==13)cout<<"\t\\\t";
- if(nb==14)cout<<"\n\tTOTAL\t";
-
- for(nbb=1;nbb<4;nbb++)
- {
- cout<<tab_v[nb][nbb]<<"\t";
- }
- cout<<"\n";
- }
-
- //test:
-
- cout<<"\n\nFin des calculs, entrer une commande: \"tout\" \"reels\" ou \"tableaux\" ";
- cin>>nom;
-
- if(!strcmp(nom,"tout"))
- {
- goto tout;
- }
- else
- {
- if(!strcmp(nom,"reels"))
- {
- goto reels;
- }
- else
- {
- if(!strcmp(nom,"tableaux"))
- {
- goto tableaux;
- }
- }
- }
- }
//******************
//*** POWER MATH ***
//******************
//Version 1.0
//Developed with Dev C++
//Programme d'evaluation de la vitesse de calcul
//Pour differents types de variables
//Affectation & operateurs
//Boucle de 1 milliard
//Test de vitesse autres fonctions
//By Alain Galiani
//Geek Star Wars 1983
//Alias Dedalusman
//nageondu@yahoo.fr
//Start 29 12 2009
//Finished 00 00 2012
//Last updat 05 03 2010
//History:
/*
Servira pour tester Geek Star Wars 1983
05 03 2010 test des tableaux global local class et struct
*/
#include<iostream.h>
#include<windows.h>
//definition des types
typedef unsigned char cop;
typedef signed char co;
typedef unsigned short m2op;
typedef signed short m2o;
typedef unsigned long lm4op;
typedef signed long lm4o;
typedef unsigned long long llm8op;
typedef signed long long llm8o;
typedef float flo4;
typedef double flo8;
typedef long double flo10;
//*** class ***
class class_objet_num
{
public:
//constructeur et destructeur inline
class_objet_num(){}
~class_objet_num(){}
flo8 tab_sommets[1000];//x
};
class class_objet_4d
{
public:
//constructeur et destructeur inline
class_objet_4d(){}
~class_objet_4d(){}
class_objet_num numerique;
};
//*** struct ***
struct struct_objet_num
{
public:
flo8 tab_sommets[1000];//x
};
class struct_objet_4d
{
public:
struct_objet_num numerique;
};
flo8 global_tab[1000];
flo8 gl1,gl2,gl3,gl4;
int main()
{
flo8 local_tab[1000];
flo8 lo1,lo2,lo3,lo4;
class_objet_4d univers[10];//univers pour 10 objets 4D
struct_objet_4d uni[10];//univers pour 10 objets 4D
//definition du ptr univers
class_objet_4d*ptr_univers;
ptr_univers=&univers[0];
//definition du ptr univers
struct_objet_4d*ptr_uni;
ptr_uni=&uni[0];
char nom[256];
//******************************************
//*** Declaration de variables entieres ***
//******************************************
//variable -128 a 127
co a1,a2,a3,a4,a5,a6,a7;
//variable -32768 a 32767
m2o b1,b2,b3,b4,b5,b6,b7;
//variable -2147483648 a 2147483647
lm4o c1,c2,c3,c4,c5,c6,c7;
//variable -9223372036854775808 a 9223372036854775807
llm8o d1,d2,d3,d4,d5,d6,d7;
//*****************************************
//*** Declaration de variables reelles ***
//*****************************************
//reel 32 bit
flo4 e1,e2,e3,e4,e5,e6,e7;
//reel 64 bit
flo8 f1,f2,f3,f4,f5,f6,f7;
//reel 80 bit
flo10 g1,g2,g3,g4,g5,g6,g7;
//variables divers
lm4op nb,nbb;
flo4 temcal;
lm4o temdeb;
flo4 tab_v[90][10];
for(nb=1;nb<90;nb++)
{
for(nbb=1;nbb<10;nbb++)
{
tab_v[nb][nbb]=1234.56;
}
}
cout<<"******************\n";
cout<<"*** POWER MATH ***\n";
cout<<"******************\n";
//goto test;
//test:
tout:
//***********************
//*** VITESSE ENTIERS ***
//***********************
cout<<"\n*** ENTIERS ***\n\n";
//teste de vitesse ************************************
temdeb=GetTickCount();
a2=45;
a3=-100;
for(nb=0;nb<1000000000;nb++)
{
a1=a2+a3;
}
temcal=(float)(GetTickCount()-temdeb)/1000.;
cout<<"a1=a2+a3 "<<int(a1)<<" entier 8 bit 1000000000 boucles = "<<temcal<<"\n";
tab_v[1][1]=temcal;
//teste de vitesse ************************************
temdeb=GetTickCount();
b2=21024;
b3=-10270;
for(nb=0;nb<1000000000;nb++)
{
b1=b2+b3;
}
temcal=(float)(GetTickCount()-temdeb)/1000.;
cout<<"b1=b2+b3 "<<b1<<" entier 16 bit 1000000000 boucles = "<<temcal<<"\n";
tab_v[1][2]=temcal;
//teste de vitesse ************************************
temdeb=GetTickCount();
c2=2007483647;
c3=-1588796587;
for(nb=0;nb<1000000000;nb++)
{
c1=c2+c3;
}
temcal=(float)(GetTickCount()-temdeb)/1000.;
cout<<"c1=c2+c3 "<<c1<<" entier 32 bit 1000000000 boucles = "<<temcal<<"\n";
tab_v[1][3]=temcal;
//teste de vitesse ************************************
temdeb=GetTickCount();
d2=8223372036854775808LL;
d3=-1223372036854775807LL;
for(nb=0;nb<1000000000;nb++)
{
d1=d2+d3;
}
temcal=(float)(GetTickCount()-temdeb)/1000.;
cout<<"d1=d2+d3 "<<d1<<" entier 64 bit 1000000000 boucles = "<<temcal<<"\n";
tab_v[1][4]=temcal;
//teste de vitesse ************************************
temdeb=GetTickCount();
a2=35;
a3=-3;
for(nb=0;nb<1000000000;nb++)
{
a1=a2*a3;
}
temcal=(float)(GetTickCount()-temdeb)/1000.;
cout<<"a1=a2*a3 "<<int(a1)<<" entier 8 bit 1000000000 boucles = "<<temcal<<"\n";
tab_v[2][1]=temcal;
//teste de vitesse ************************************
temdeb=GetTickCount();
b2=2102;
b3=-11;
for(nb=0;nb<1000000000;nb++)
{
b1=b2*b3;
}
temcal=(float)(GetTickCount()-temdeb)/1000.;
cout<<"b1=b2*b3 "<<b1<<" entier 16 bit 1000000000 boucles = "<<temcal<<"\n";
tab_v[2][2]=temcal;
//teste de vitesse ************************************
temdeb=GetTickCount();
c2=2007483;
c3=-658;
for(nb=0;nb<1000000000;nb++)
{
c1=c2*c3;
}
temcal=(float)(GetTickCount()-temdeb)/1000.;
cout<<"c1=c2*c3 "<<c1<<" entier 32 bit 1000000000 boucles = "<<temcal<<"\n";
tab_v[2][3]=temcal;
//teste de vitesse ************************************
temdeb=GetTickCount();
d2=12345678901234LL;
d3=-12345LL;
for(nb=0;nb<1000000000;nb++)
{
d1=d2*d3;
}
temcal=(float)(GetTickCount()-temdeb)/1000.;
cout<<"d1=d2*d3 "<<d1<<" entier 64 bit 1000000000 boucles = "<<temcal<<"\n";
tab_v[2][4]=temcal;
//teste de vitesse ************************************
temdeb=GetTickCount();
a2=123;
a3=-13;
for(nb=0;nb<1000000000;nb++)
{
a1=a2/a3;
}
temcal=(float)(GetTickCount()-temdeb)/1000.;
cout<<"a1=a2/a3 "<<int(a1)<<" entier 8 bit 1000000000 boucles = "<<temcal<<"\n";
tab_v[3][1]=temcal;
//teste de vitesse ************************************
temdeb=GetTickCount();
b2=21024;
b3=-123;
for(nb=0;nb<1000000000;nb++)
{
b1=b2/b3;
}
temcal=(float)(GetTickCount()-temdeb)/1000.;
cout<<"b1=b2/b3 "<<b1<<" entier 16 bit 1000000000 boucles = "<<temcal<<"\n";
tab_v[3][2]=temcal;
//teste de vitesse ************************************
temdeb=GetTickCount();
c2=2007483647;
c3=-15887;
for(nb=0;nb<1000000000;nb++)
{
c1=c2/c3;
}
temcal=(float)(GetTickCount()-temdeb)/1000.;
cout<<"c1=c2/c3 "<<c1<<" entier 32 bit 1000000000 boucles = "<<temcal<<"\n";
tab_v[3][3]=temcal;
//teste de vitesse ************************************
temdeb=GetTickCount();
d2=8223372036854775808LL;
d3=-1223372036LL;
for(nb=0;nb<1000000000;nb++)
{
d1=d2/d3;
}
temcal=(float)(GetTickCount()-temdeb)/1000.;
cout<<"d1=d2/d3 "<<d1<<" entier 64 bit 1000000000 boucles = "<<temcal<<"\n";
tab_v[3][4]=temcal;
tab_v[4][1]=tab_v[1][1]+tab_v[2][1]+tab_v[3][1];
tab_v[4][2]=tab_v[1][2]+tab_v[2][2]+tab_v[3][2];
tab_v[4][3]=tab_v[1][3]+tab_v[2][3]+tab_v[3][3];
tab_v[4][4]=tab_v[1][4]+tab_v[2][4]+tab_v[3][4];
//teste de vitesse ************************************
temdeb=GetTickCount();
a2=123;
b3=4;
for(nb=0;nb<1000000000;nb++)
{
a1=a2>>b3;
}
temcal=(float)(GetTickCount()-temdeb)/1000.;
cout<<"a1=a2>>b3 "<<int(a1)<<" entier 8 bit 1000000000 boucles = "<<temcal<<"\n";
tab_v[5][1]=temcal;
//teste de vitesse ************************************
temdeb=GetTickCount();
b2=-31123;
b3=8;
for(nb=0;nb<1000000000;nb++)
{
b1=b2>>b3;
}
temcal=(float)(GetTickCount()-temdeb)/1000.;
cout<<"b1=b2>>b3 "<<b1<<" entier 16 bit 1000000000 boucles = "<<temcal<<"\n";
tab_v[5][2]=temcal;
//teste de vitesse ************************************
temdeb=GetTickCount();
c2=2147483640;
b3=10;
for(nb=0;nb<1000000000;nb++)
{
c1=c2>>b3;
}
temcal=(float)(GetTickCount()-temdeb)/1000.;
cout<<"c1=c2>>b3 "<<c1<<" entier 32 bit 1000000000 boucles = "<<temcal<<"\n";
tab_v[5][3]=temcal;
//teste de vitesse ************************************
temdeb=GetTickCount();
d2=-8223372036854775808LL;
b3=10;
for(nb=0;nb<1000000000;nb++)
{
d1=d2>>b3;
}
temcal=(float)(GetTickCount()-temdeb)/1000.;
cout<<"d1=d2>>b3 "<<d1<<" entier 64 bit 1000000000 boucles = "<<temcal<<"\n";
tab_v[5][4]=temcal;
tab_v[6][1]=tab_v[5][1]+tab_v[4][1];
tab_v[6][2]=tab_v[5][2]+tab_v[4][2];
tab_v[6][3]=tab_v[5][3]+tab_v[4][3];
tab_v[6][4]=tab_v[5][4]+tab_v[4][4];
reels:
//*********************
//*** VITESSE REELS ***
//*********************
cout<<"\n*** REELS ***\n\n";
//teste de vitesse ************************************
temdeb=GetTickCount();
e2=12345.6789;
e3=-9876.54321;
for(nb=0;nb<1000000000;nb++)
{
e1=e2+e3;
}
temcal=(float)(GetTickCount()-temdeb)/1000.;
cout<<"e1=e2+e3 "<<e1<<" reel 32 bit 1000000000 boucles = "<<temcal<<"\n";
tab_v[11][1]=temcal;
//teste de vitesse ************************************
temdeb=GetTickCount();
f2=123456789.1234567;
f3=-9876543.7654321;
for(nb=0;nb<1000000000;nb++)
{
f1=f2+f3;
}
temcal=(float)(GetTickCount()-temdeb)/1000.;
cout<<"f1=f2+f3 "<<f1<<" reel 64 bit 1000000000 boucles = "<<temcal<<"\n";
tab_v[11][2]=temcal;
//teste de vitesse ************************************
temdeb=GetTickCount();
g2=1234567890123.123456789012;
g3=-9876543210.987654321;
for(nb=0;nb<1000000000;nb++)
{
g1=g2+g3;
}
temcal=(float)(GetTickCount()-temdeb)/1000.;
cout<<"g1=g2+g3 "<<g1<<" reel 80 bit 1000000000 boucles = "<<temcal<<"\n";
tab_v[11][3]=temcal;
//teste de vitesse ************************************
temdeb=GetTickCount();
e2=12345.6789;
e3=-98.54321;
for(nb=0;nb<1000000000;nb++)
{
e1=e2*e3;
}
temcal=(float)(GetTickCount()-temdeb)/1000.;
cout<<"e1=e2*e3 "<<e1<<" reel 32 bit 1000000000 boucles = "<<temcal<<"\n";
tab_v[12][1]=temcal;
//teste de vitesse ************************************
temdeb=GetTickCount();
f2=1234567.1234567;
f3=-987.7654321;
for(nb=0;nb<1000000000;nb++)
{
f1=f2*f3;
}
temcal=(float)(GetTickCount()-temdeb)/1000.;
cout<<"f1=f2*f3 "<<f1<<" reel 64 bit 1000000000 boucles = "<<temcal<<"\n";
tab_v[12][2]=temcal;
//teste de vitesse ************************************
temdeb=GetTickCount();
g2=1234567123.123456789012;
g3=-98765.987654321;
for(nb=0;nb<1000000000;nb++)
{
g1=g2*g3;
}
temcal=(float)(GetTickCount()-temdeb)/1000.;
cout<<"g1=g2*g3 "<<g1<<" reel 80 bit 1000000000 boucles = "<<temcal<<"\n";
tab_v[12][3]=temcal;
//teste de vitesse ************************************
temdeb=GetTickCount();
e2=12345.6789;
e3=-98.54321;
for(nb=0;nb<1000000000;nb++)
{
e1=e2/e3;
}
temcal=(float)(GetTickCount()-temdeb)/1000.;
cout<<"e1=e2/e3 "<<e1<<" reel 32 bit 1000000000 boucles = "<<temcal<<"\n";
tab_v[13][1]=temcal;
//teste de vitesse ************************************
temdeb=GetTickCount();
f2=1234567.1234567;
f3=-987.7654321;
for(nb=0;nb<1000000000;nb++)
{
f1=f2/f3;
}
temcal=(float)(GetTickCount()-temdeb)/1000.;
cout<<"f1=f2/f3 "<<f1<<" reel 64 bit 1000000000 boucles = "<<temcal<<"\n";
tab_v[13][2]=temcal;
//teste de vitesse ************************************
temdeb=GetTickCount();
g2=1234567123.123456789012;
g3=-98765.987654321;
for(nb=0;nb<1000000000;nb++)
{
g1=g2/g3;
}
temcal=(float)(GetTickCount()-temdeb)/1000.;
cout<<"g1=g2/g3 "<<g1<<" reel 80 bit 1000000000 boucles = "<<temcal<<"\n";
tab_v[13][3]=temcal;
//test:
tableaux:
//******************************************************
//*** VITESSE I/O TABLEAUX GLOBAL LOCAL CLASS STRUCT ***
//******************************************************
cout<<"\n*** VITESSE I/O TABLEAUX GLOBAL LOCAL CLASS STRUCT ***\n\n";
//teste de vitesse ************************************
temdeb=GetTickCount();
gl1=123456789;
for(nb=0;nb<1000000;nb++)
{
for(int nb2=0;nb2<1000;nb2++)
{
global_tab[nb2]=gl1;
gl2=global_tab[nb2];
}
}
temcal=(float)(GetTickCount()-temdeb)/1000.;
cout<<"flo8 global_tab[1000] entree et sortie 1000000 boucles = "<<temcal<<"\n";
//teste de vitesse ************************************
temdeb=GetTickCount();
lo1=123456789;
for(nb=0;nb<1000000;nb++)
{
for(int nb2=0;nb2<1000;nb2++)
{
local_tab[nb2]=lo1;
lo2=local_tab[nb2];
}
}
temcal=(float)(GetTickCount()-temdeb)/1000.;
cout<<"flo8 local_tab[1000] entree et sortie 1000000 boucles = "<<temcal<<"\n";
//teste de vitesse ************************************
temdeb=GetTickCount();
lo1=123456789;
for(nb=0;nb<1000000;nb++)
{
for(int nb2=0;nb2<1000;nb2++)
{
ptr_univers->numerique.tab_sommets[nb2]=lo1;
lo2=ptr_univers->numerique.tab_sommets[nb2];
}
}
temcal=(float)(GetTickCount()-temdeb)/1000.;
cout<<"flo8 CLASS univers[0].numerique.tab_sommets[1000] I/O 1000000 bcl = "<<temcal<<"\n";
//teste de vitesse ************************************
temdeb=GetTickCount();
lo1=123456789;
for(nb=0;nb<1000000;nb++)
{
for(int nb2=0;nb2<1000;nb2++)
{
ptr_uni->numerique.tab_sommets[nb2]=lo1;
lo2=ptr_uni->numerique.tab_sommets[nb2];
}
}
temcal=(float)(GetTickCount()-temdeb)/1000.;
cout<<"flo8 STRUCT uni[0].numerique.tab_sommets[1000] I/O 1000000 bcl = "<<temcal<<"\n";
tab_v[14][1]=tab_v[11][1]+tab_v[12][1]+tab_v[13][1];
tab_v[14][2]=tab_v[11][2]+tab_v[12][2]+tab_v[13][2];
tab_v[14][3]=tab_v[11][3]+tab_v[12][3]+tab_v[13][3];
//test:
cout<<"\n\n\t\t*** TABLEAU ENTIERS ***\n\n";
cout<<"\t\t8 bit\t16 bit\t32 bit\t64 bit\n\n";
for(nb=1;nb<7;nb++)
{
if(nb==1)cout<<"\t+\t";
if(nb==2)cout<<"\t*\t";
if(nb==3)cout<<"\t\\\t";
if(nb==4)cout<<"\n\tS_TOT\t";
if(nb==5)cout<<"\n\t>>\t";
if(nb==6)cout<<"\n\tTOTAL\t";
for(nbb=1;nbb<5;nbb++)
{
cout<<tab_v[nb][nbb]<<"\t";
}
cout<<"\n";
}
cout<<"\n\n\t\t*** TABLEAU REELS ***\n\n";
cout<<"\t\t32 bit\t64 bit\t80 bit\n\n";
for(nb=11;nb<15;nb++)
{
if(nb==11)cout<<"\t+\t";
if(nb==12)cout<<"\t*\t";
if(nb==13)cout<<"\t\\\t";
if(nb==14)cout<<"\n\tTOTAL\t";
for(nbb=1;nbb<4;nbb++)
{
cout<<tab_v[nb][nbb]<<"\t";
}
cout<<"\n";
}
//test:
cout<<"\n\nFin des calculs, entrer une commande: \"tout\" \"reels\" ou \"tableaux\" ";
cin>>nom;
if(!strcmp(nom,"tout"))
{
goto tout;
}
else
{
if(!strcmp(nom,"reels"))
{
goto reels;
}
else
{
if(!strcmp(nom,"tableaux"))
{
goto tableaux;
}
}
}
}
Conclusion
Sauf erreur de programmation de ma part, c'est extrêmement rapide. D'autant que mes premiers ordinateurs furent un Atari 800XL puis un 520STF.
Historique
- 06 mars 2010 10:25:09 :
- pas de modification du code mais ajout d'une capture ecran
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
[Directx] Deplacement et vitesse d'une balle selon le cpu ? [ par skeleton ]
Salut, voila mon probleme je me test avec directx en faisant un casse brique mais voila que je tombe sur un probleme (qui commence a me faire rager et
Augmenter vitesse d'exécution [ par scelw ]
Bonjour, Je "m'amuse" avec des nombres premiers de très grande taille. Le temps d'exécution de mon programme est très long. Pour aboutir, il faut souv
temps d'exécution d'un processus (c/linux) [ par davidauche ]
bonjour a tt monde,comment calculer le temps d'exécution d'un processus en c sous linux!?j'essaie avec time et times + struct tms marc
Vitesse de calculs [ par elflink ]
Bonjour à tous,Je travaille en API, C++.Je m'exerce sur l'élaboration d'un outil de dessinage, et de la même manière que MSPAINT,
Priorité et thread [ par obasileus ]
Salut, j'ai un programme qui tourne avec 2 thread utilisant une même ressource partagé. Je voudrai privilégier l'execution d'un des de
Lecture sur le port série en Borland C++ [ par Kurul1 ]
Bonjour à tousJe voudrais savoir comment faire avec Borland C++ pour lire des informations sur un port série. il faudrais également que
comment gerer les retour dans un fichier. [ par casper_2 ]
Bonjour jaimerai que dans mon fichier,les retour chariot,soit gerer!!En faite j'aimerai qu'après chaque ecriture,dans le fichier il puisse m'ecri
RS232 vitesse differente RX TX [ par bobnono ]
Bonjour tout le monde, est-ce possible d'avoir une connexion série rs232 ou la reception est à 32120 bauds et l'émission 
Comparaison De Deux Réels En C/C++ [ par Ombitious_Developper ]
Salut :Je Souhaite Savoir Comment Comparer Deux Réels En C/C++.En effet, Si On Considère :float A;float B;if(A = = B){ .....}Cette Comparais
Vitesse de traitement entre _write et fwrite [ par PeteTheBull ]
Bonjour Dans mon programme, je sauvegarde des données (issues d'une acquisition video) sur mon disque soit en utilisant la fonction "_write", so
|
Derniers Blogs
IMAGINE CUP 2012, MAKE A SIGN EN FINALEIMAGINE CUP 2012, MAKE A SIGN EN FINALE par junarnoalg
Voilà qui est fait, la nouvelle est officielle ! L'équipe belge "Make a Sign" va au pays des kangourous défendre son projet dans la catégorie Software Design. http://www.imaginecup.com/CompetitionsContent/Competition/WorldwideFinalists.aspx V...
Cliquez pour lire la suite de l'article par junarnoalg KINECT 1.5 IS OUT !KINECT 1.5 IS OUT ! par Vko
La version 1.5 du Kinect For Microsoft vient tout juste de sortir ! Plein de nouveautés: Tracking de squelette en Near Mode Détection en position assise Détection faciale avec un SDK dédié Documentation et des guideline (enfin) Un out...
Cliquez pour lire la suite de l'article par Vko LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) par richardc
Mise à jour des Web API du 14 Mai
Réservez dès maintenant votre journée du 20 juin pour le Windows Azure Dev Camp 2012 à Paris
Mise à jour de Team Foundation Service
MechCommander 2 sur Windows 8
Entity Framework 5 Release Candidate e...
Cliquez pour lire la suite de l'article par richardc REACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITERREACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITER par Groc
Une mauvaise utilisation de rx lors de l'écriture d'une couche d'accès à des services peut conduire à des cas embarassants avec des erreurs mal gérées, des appels qui ne partent lorsqu'ils le devraient, et même des résultats incorrects . le tout nuis...
Cliquez pour lire la suite de l'article par Groc SHAREPOINT BLOG SITE, PROBLèME D'ARCHIVESSHAREPOINT BLOG SITE, PROBLèME D'ARCHIVES par junarnoalg
Dernièrement, nous avons migré le site
myTIC
vers un nouveau serveur SharePoint 2010. Dans les contenus que nous vouloins récupérer, nous avions un certain nombre de blogs.
Nous avons utilisé les commandes Power...
Cliquez pour lire la suite de l'article par junarnoalg
Forum
MATRICE TEMPLATEMATRICE TEMPLATE par hjr2610
Cliquez pour lire la suite par hjr2610 RE : SAC A DOS RE : SAC A DOS par hadjkaddour
Cliquez pour lire la suite par hadjkaddour
Logiciels
sDEVIS-FACTURES vlPRO (8.1.0.3)SDEVIS-FACTURES VLPRO (8.1.0.3)sDEVIS-FACTURES vlPRO a été mis au point pour les particuliers, créateurs, entrepreneurs, artisa... Cliquez pour télécharger sDEVIS-FACTURES vlPRO 974 Application Server (12.2.4.6)974 APPLICATION SERVER (12.2.4.6)Développez de puissantes applications dans un environnement de 'cloud computing', clusterisé, séc... Cliquez pour télécharger 974 Application Server vPicture (1.4.2.1)VPICTURE (1.4.2.1)Avec vPicture, hébergez vos images facilement et rapidement.
vPicture est un utilitaire simple, ... Cliquez pour télécharger vPicture Easy-Planning (2.2.1.6)EASY-PLANNING (2.2.1.6)Easy-Planning permet de créer des plannings sous la représentation de diagrammes et est adapté au... Cliquez pour télécharger Easy-Planning COM-BACKUP (2.0)COM-BACKUP (2.0)
COM-BACKUP est un logiciel de sauvegarde qui permet de planifier les sauvegardes de vos dossiers ...
Cliquez pour télécharger COM-BACKUP
|