run slow

hey guys; I am very new in c++ , I try to run this code with code block, but it is too slow and take long time, I really appreciate any sort of help or tips to help me.
#include <iostream>
#include <tuple>
#include <cmath>
#include <fstream>
#include <cstdlib>
#include "libxl.h"
#include <sstream>
#include <string>
#include <cstdio>
#include <ctime>
#include <cstdint>
using namespace std;
using namespace libxl;

int main()
{
char seriesfilename[50] ="Logistic1500.csv";
int numtests =100;
double sq_variation[numtests];
double mean_sq_variation = 0;
double stdeviation_sq_variation = 0;

stringstream ss0;
ss0 << "testresults_(" << seriesfilename
<< "_opt. method=randomsearch_Poincare.method=intersect_windowsize=1000_optimizeit=1000).xls";

string stringresultfilename0 = ss0.str();

char * charresultfilename0 = new char[stringresultfilename0.size() + 1];
copy(stringresultfilename0.begin(), stringresultfilename0.end(), charresultfilename0);
charresultfilename0[stringresultfilename0.size()] = '\0';

for (int index1 = 0;index1 < numtests; index1++ )
{
system("F:\\seriestests\\optimalcheck.exe");

Book* book = xlCreateBook();

if(book->load(charresultfilename0))
{
Sheet* sheet = book->getSheet(0);
if(sheet)
{
double dummyvar = 1;
int row = 2;
while (dummyvar!=0)
{
sq_variation[index1] = dummyvar;
dummyvar = sheet->readNum(row, 1);
row++;
}
}
}

book->release();
}

for (int i=0; i < numtests;i++)
{
mean_sq_variation = mean_sq_variation + sq_variation[i];
}
mean_sq_variation = mean_sq_variation/numtests;

for (int i = 0; i < numtests;i++)
{
stdeviation_sq_variation = stdeviation_sq_variation + pow(abs(mean_sq_variation-sq_variation[i]),2);
}
stdeviation_sq_variation = sqrt(stdeviation_sq_variation/numtests);

Book* book2 = xlCreateBook();

Font* textFont = book2->addFont();
textFont->setSize(12);
textFont->setName("Times New Roman");

Font* titleFont = book2->addFont(textFont);
titleFont->setSize(38);
titleFont->setColor(COLOR_GRAY25);

Font* font12 = book2->addFont(textFont);
font12->setSize(12);

Font* font10 = book2->addFont(textFont);
font10->setSize(10);

// formats________________________________________

Format* textFormat = book2->addFormat();
textFormat->setFont(textFont);
textFormat->setAlignH(ALIGNH_LEFT);

Format* titleFormat = book2->addFormat();
titleFormat->setFont(titleFont);
titleFormat->setAlignH(ALIGNH_RIGHT);

Format* borderFormat = book2->addFormat(textFormat);
borderFormat->setBorder();
borderFormat->setBorderColor(COLOR_GRAY25);
borderFormat->setAlignV(ALIGNV_CENTER);

Format* textRightFormat = book2->addFormat(textFormat);
textRightFormat->setAlignH(ALIGNH_RIGHT);
textRightFormat->setAlignV(ALIGNV_CENTER);

// RESULTS SHEET_________________________________
Sheet* resultssheet = book2->addSheet("Results");
resultssheet->setDisplayGridlines(true);

//SET COLUMN WIDTHS, ETC.
resultssheet->setCol(1, 1, 15);
resultssheet->setCol(2, 2, 12);

Sheet* sheet = book2->getSheet(0);

// items
resultssheet->writeStr(1, 0, "Opt. Check #", textFormat);
resultssheet->writeStr(1, 1, "Sq. Variation", textFormat);

resultssheet->writeStr(1, 2, "mean", textFormat);
resultssheet->writeNum(2, 2, mean_sq_variation, textFormat);//SQUARE VARIATION

resultssheet->writeStr(1, 3, "St. Deviation", textFormat);
resultssheet->writeNum(2, 3, stdeviation_sq_variation, textFormat);//SQUARE VARIATION
for(int x = 0; x< numtests;x++)
{
resultssheet->writeNum(x+2, 0, x+1, textFormat);//trial column #'s
resultssheet->writeNum(x+2, 1, sq_variation[x], textFormat);//SQUARE VARIATION
}
stringstream ss;
ss << "Results(" << seriesfilename
<< ").xls";
string stringresultfilename = ss.str();

char * charresultfilename = new char[stringresultfilename.size() + 1];
copy(stringresultfilename.begin(), stringresultfilename.end(), charresultfilename);
charresultfilename[stringresultfilename.size()] = '\0';

book2->save(charresultfilename);

book2->release();

return 0;
}
Firstly, for future reference please use to format your code so that we can read it easier and secondly, im pretty sure your computer is just struggling to compile the code and I don't think there's anything you can do for it to run faster. All computers are different and slower computers will take time to compile the code.
Topic archived. No new replies allowed.