Witam, muszę napisać program odczytujący prędkość zapisu pamięci RAM. Napisałem takie oto cudo, wg mnie powinno smigac i wyswietlac poprawne dane. Jednak tak nie jest, porównywałem z everestem, gdzie średnio predkosc zapisu w moim programie bylo 2 razy mniejsza niz w everescie. Mogłby mnie ktoś uswiadomic co robie zle? Z góry dzieki :)
#include <cstdlib>
#include <iostream>
#include <time.h>
#include <math.h>
#include <iomanip>
#include <windows.h>
using namespace std;
int main(){
double *tab,c=0,x=0,s;
long int i;
clock_t start, stop;
tab=(double*)malloc(sizeof(double)*67108864);
start=clock();
//start=GetTickCount();
for(i=0;i<67108864;i++){
tab[i]=i; //131072*8=1MB 4194304*8=32MB 8388608*8=64MB
c=c+sizeof(tab[i]); //16777216*8=128MB 67108864*8=512M 134217728*8=1GB
}
stop=clock();
//stop=GetTickCount();
free(tab);
x=((double) (stop - start)) /CLOCKS_PER_SEC;
cout<<"czas pomiaru: "<<fixed<<setprecision(3)<<x<<" sek."<<endl;
cout<<endl;
cout<<"przerzucono: "<<setprecision(0)<<c/1024<<" KB\t\t"<<c/1024/1024<<" MB"<<endl;
s=c/x;
cout<<"z predkoscia: "<<setprecision(2)<<s/1024<<" KB/s\t"<<s/1024/1024<<" MB/s"<<endl;
getchar();
}