hi people...this is my first post on this forum so i hope you won't get angry if i jump straight to my problem...
you see i'm not that good in c++, but am getting a hang of it.so to upgrade my skills i write little programs for fun. this one is a small benchmark program that uses several mathematical algorithms to measure the speed of the processor by the time it takes them to run the algorithms.
the core of the program is complete and works. but i want to implement a function that will get the os version, cpuid, date and time and display it in the program and a graph that will be used to compare the different results.
all the results are stored in seperate *.txt files and the sum of all results also in a seperate file.
so the question is if you can help me implement this features...and i hope i explained the way the program works and what i want to modify.
thanks for the help in advance.
the code is
void PascalovTrokut();
void PrimBrojevi();
void Pi();
void CBenchmarkDlg::OnTestiraj()
{
UpdateData(TRUE);
if(m_cNaziv == "") {
MessageBox("Niste unesli tip procesora !!!", "Greska", 48);
return;
}
if((m_bTest1 || m_bTest2 || m_bTest3) != TRUE) {
MessageBox("Niste izabrali nijedan test !!!", "Greska", 48);
return;
}
m_iRezVri1 = 0;
m_iRezVri2 = 0;
m_iRezVri3 = 0;
m_iRezUkVri = 0;
m_iVrijeme1 = 0;
m_iVrijeme2 = 0;
m_iVrijeme3 = 0;
m_iUkupnoVri = 0;
UpdateData(FALSE);
time_t prvo;
time_t drugo;
GetDlgItem(IDC_TESTIRAJ)->EnableWindow(FALSE);
GetDlgItem(IDC_IZLAZ)->EnableWindow(FALSE);
if(m_bTest1 == TRUE) {
time(&prvo);
PascalovTrokut();
time(&drugo);
m_iRezVri1 = drugo - prvo;
m_iVrijeme1 = m_iRezVri1;
UpdateData(FALSE);
}
if(m_bTest2 == TRUE) {
time(&prvo);
PrimBrojevi();
time(&drugo);
m_iRezVri2 = drugo - prvo;
m_iVrijeme2 = m_iRezVri2;
UpdateData(FALSE);
}
if(m_bTest3 == TRUE) {
time(&prvo);
Pi();
time(&drugo);
m_iRezVri3 = drugo - prvo;
m_iVrijeme3 = m_iRezVri3;
UpdateData(FALSE);
}
m_iRezUkVri = m_iRezVri1 + m_iRezVri2 + m_iRezVri3;
m_iUkupnoVri = m_iRezUkVri;
GetDlgItem(IDC_TESTIRAJ)->EnableWindow(TRUE);
GetDlgItem(IDC_IZLAZ)->EnableWindow(TRUE);
UpdateData(FALSE);
if(m_iRezUkVri != 0) {
char vrijeme[3];
fstream dat;
dat.open("Rezultati.txt", ios::app | ios::out);
dat << m_cNaziv << "\n------------------\n";
if(m_bTest1 == TRUE) {
dat << "Test1: ";
_itoa(m_iRezVri1, vrijeme, 10);
dat << vrijeme << " sekundi\n";
}
if(m_bTest2 == TRUE) {
dat << "Test2: ";
_itoa(m_iRezVri2, vrijeme, 10);
dat << vrijeme << " sekundi\n";
}
if(m_bTest3 == TRUE) {
dat << "Test3: ";
_itoa(m_iRezVri3, vrijeme, 10);
dat << vrijeme << " sekundi\n";
}
dat << "Ukupno: ";
_itoa(m_iRezUkVri, vrijeme, 10);
dat << vrijeme << " sekundi\n******************\n\n";
dat.close();
}
}
void PascalovTrokut() {
unsigned long br[50000];
int brojac = 1;
int brojac2;
for(brojac; brojac <= 50000; brojac++) {
int opcija = 0;
for(brojac2 = 0; brojac2 < brojac; brojac2++) {
switch(opcija) {
case 0: br[brojac2] = 1; break;
case 1: br[brojac2] = br[brojac2 - 1] + br[brojac2]; break;
case 2: br[brojac2] = 1; break;
}
if(brojac2 == brojac - 2) opcija = 2;
else opcija = 1;
}
}
}
void PrimBrojevi() {
fstream dat;
dat.open("Primbrojevi.txt", ios::out | ios::trunc);
dat << "Prosti brojevi do 100000:\n\n";
int broj;
bool primbr;
char primbroj[6];
for(broj = 3; broj <= 100000; broj++) {
primbr = TRUE;
for(int x = 2; x < broj; x++) {
if(broj % x == 0) {
primbr = FALSE;
break;
}
}
if(primbr == TRUE) {
_itoa(broj, primbroj, 10);
dat << primbroj << "\n";
}
}
dat.close();
}
void Pi() {
fstream dat;
dat.open("Pi.txt", ios::out | ios::trunc);
double pi = 0;
for(int x = 1; x < 2000000000; x += 2) {
if(x % 4 == 1) pi = pi + double(double(1) / x);
else pi = pi - double(double(1) / x);
}
pi = pi * double(4);
dat << "Pi = " << pi;
dat.close();
}
void CBenchmarkDlg::OnIzlaz()
{
OnOK();
}
void CBenchmarkDlg::OnAbout()
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}