When I run my code below I get a value 0, a few times I did get a value for the intAddition. I've tried many suggestions I found online, but have yet to prevail. My classmate showed me how he did his and it was very similar to mine. He was getting small values, 1 to 3, from his program.
Thanks for the help!
#include <iostream>
#include <time.h>
#include <stdio.h>
clock_t start, end;
void intAddition(int a, int b){
start = clock();
a + b;
end = clock();
printf("CPU cycles to execute integer addition operation: %d\n", end-start);
}
void intMult(int a, int b){
start = clock();
a * b;
end = clock();;
printf("CPU cycles to execute integer multiplication operation: %d\n", end-start);
}
void floatAddition(float a, float b){
start = clock();
a + b;
end = clock();;;
printf("CPU cycles to execute float addition operation: %d\n", end-start);
}
void floatMult(float a, float b){
start = clock();
a * b;
end = clock();;
printf("CPU cycles to execute float multiplication operation: %d\n", end-start);
}
int main()
{
int a,b;
float c,d;
a = 3, b = 6;
c = 3.7534, b = 6.85464;
intAddition(a,b);
intMult(a,b);
floatAddition(c,d);
floatMult(c,d);
return 0;
}
Aucun commentaire:
Enregistrer un commentaire