Example #1
0
void Builder::makeFibonacci()
{
	int whitchNumber;
	Fibonacci fib;
	cout << "podaj który elemen ci¹gu chcesz ";
	cin >> whitchNumber;

	cout << "--------------proba czasow dla ci¹gu fibonacziego------------- " << endl;
	cout << "rekurencyjnie robi to w czasie: ";
	CountStart = startTimer();
	fib.fibonaciiR(whitchNumber);
	CountEnd = endTimer();
	timeOperation.QuadPart = CountEnd.QuadPart - CountStart.QuadPart;
	QueryPerformanceFrequency(&freq);
	tm = ((double)timeOperation.QuadPart) * 1000000000 / freq.QuadPart;	//bedzie w nano sekundach
	cout << tm << endl << "a wynik to: " << fib.fibonaciiR(whitchNumber);
	cout << endl << endl;

	cout << "moje robi to w czasie: ";
	CountStart = startTimer();
	fib.fibonaciiMoj(whitchNumber);
	CountEnd = endTimer();
	timeOperation.QuadPart = CountEnd.QuadPart - CountStart.QuadPart;
	QueryPerformanceFrequency(&freq);
	tm = ((double)timeOperation.QuadPart) * 1000000000 / freq.QuadPart;	//bedzie w nano sekundach
	cout << tm << endl << "a wynik to: " << fib.fibonaciiMoj(whitchNumber);
	cout << endl << endl;
}
Example #2
0
void Builder::makeEuklides()
{
	int a, b;
	Euklides e;
	cout << "podaj który elemen ci¹gu chcesz ";
	cin >> a >> b;

	cout << "--------------proba czasow dla ci¹gu fibonacziego------------- " << endl;
	cout << "whilem robi to w czasie: ";
	CountStart = startTimer();
	e.EuklidesWhilem(a, b);
	CountEnd = endTimer();
	timeOperation.QuadPart = CountEnd.QuadPart - CountStart.QuadPart;
	QueryPerformanceFrequency(&freq);
	tm = ((double)timeOperation.QuadPart) * 1000000000 / freq.QuadPart;	//bedzie w nano sekundach
	cout << tm << endl << "a wynik to: " << e.EuklidesWhilem(a, b);
	cout << endl << endl;

	cout << "whilem po modyfikacji robi to w czasie: ";
	CountStart = startTimer();
	e.EuklidesWhilemMod(a, b);
	CountEnd = endTimer();
	timeOperation.QuadPart = CountEnd.QuadPart - CountStart.QuadPart;
	QueryPerformanceFrequency(&freq);
	tm = ((double)timeOperation.QuadPart) * 1000000000 / freq.QuadPart;	//bedzie w nano sekundach
	cout << tm << endl << "a wynik to: " << e.EuklidesWhilemMod(a, b);
	cout << endl << endl;
}
Example #3
0
void heartbeat() {
    float now = getCurrentTime() / (float)1000.0;

    startTimer();
    checkCollisions();
    cellsClear(cells);

    cvsFillStyle("black");
    cvsFillRect(0, 0, getWidth(), getHeight());

    for(int i=0; i<numEntities; i++) {
        Entity *ent = objects[i];

        if(ent) {
            updateEntity(ent, now - last);
            renderEntity(ent);

            cellsAdd(cells, ent, ent->pos.x, ent->pos.y);
            cellsAdd(cells, ent, ent->pos.x + ent->size.x, ent->pos.y);
            cellsAdd(cells, ent, ent->pos.x, ent->pos.y + ent->size.y);
            cellsAdd(cells, ent,
                     ent->pos.x + ent->size.x,
                     ent->pos.y + ent->size.y);

        }
    }

    //renderDebug();

    endTimer();
    last = now;
}
static void doLoop(bool warmup, int pgm, uint32_t passCount) {
    if (warmup) {
        glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
        ptSwap();
        glFinish();
        return;
    }

    startTimer();
    glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
    for (uint32_t ct=0; ct < passCount; ct++) {
        int loc = glGetUniformLocation(pgm, "u_texOff");
        glUniform2f(loc, ((float)ct) / passCount, ((float)ct) / 2.f / passCount);

        randUniform(pgm, "u_color");
        randUniform(pgm, "u_0");
        randUniform(pgm, "u_1");
        randUniform(pgm, "u_2");
        randUniform(pgm, "u_3");
        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
    }
    ptSwap();
    glFinish();
    endTimer(passCount);
}
Example #5
0
void Builder::makeFactorial()		//dziwne rzeczy bo for najszybszy 
{
	int howMuchElementsOfFactorial;
	Factorial f;
	cout << "podaj do ile el silni ";
	cin >> howMuchElementsOfFactorial;

	cout << "--------------proba czasow dla silni------------- " << endl;

	cout << "rekurencyjnie robi to w czasie: ";
	CountStart = startTimer();
	f.factorialR(howMuchElementsOfFactorial);
	CountEnd = endTimer();
	timeOperation.QuadPart = CountEnd.QuadPart - CountStart.QuadPart;
	QueryPerformanceFrequency(&freq);
	tm = ((double)timeOperation.QuadPart) * 1000000000 / freq.QuadPart;	//bedzie w nano sekundach
	cout << tm << endl << "a wynik to: " << f.factorialR(howMuchElementsOfFactorial);
	cout << endl << endl;

	cout << "iteracyjnie(whilem) robi w czasie: ";
	CountStart = startTimer();
	f.factorialIter(howMuchElementsOfFactorial);
	CountEnd = endTimer();
	timeOperation.QuadPart = CountEnd.QuadPart - CountStart.QuadPart;
	QueryPerformanceFrequency(&freq);
	tm = ((double)timeOperation.QuadPart) * 1000000000 / freq.QuadPart;	//bedzie w nano sekundach
	cout << tm << endl << "a wynik to: " << f.factorialIter(howMuchElementsOfFactorial);
	cout << endl << endl;

	cout << "interacyjnie(na forze) robi w czasie: ";
	CountStart = startTimer();
	f.factorialIterFor(howMuchElementsOfFactorial);
	CountEnd = endTimer();
	timeOperation.QuadPart = CountEnd.QuadPart - CountStart.QuadPart;
	QueryPerformanceFrequency(&freq);
	tm = ((double)timeOperation.QuadPart) * 1000000000 / freq.QuadPart;	//bedzie w nano sekundach
	cout << tm << endl << "a wynik to: " << f.factorialIterFor(howMuchElementsOfFactorial);
	cout << endl << endl;

}
Example #6
0
TimerWidget::TimerWidget(QWidget* parent)
   : QWidget(parent),
     hours(0),
     minutes(0),
     seconds(0),
     start(true),
     timer(new QTimer(this)),
     flashTimer(new QTimer(this)),
     paletteOld(),
     paletteNew(),
     mediaPlayer(new QMediaPlayer(this)),
     playlist(new QMediaPlaylist(mediaPlayer)),
     oldColors(true)
{
   doLayout();

   // One second between timeouts.
   timer->setInterval(1000);
   flashTimer->setInterval(500);

   playlist->setPlaybackMode(QMediaPlaylist::Loop);
   mediaPlayer->setVolume(100);
   mediaPlayer->setPlaylist(playlist);

   paletteOld = lcdNumber->palette();
   paletteNew = QPalette(paletteOld);
   // Swap colors.
   paletteNew.setColor(QPalette::Active, QPalette::WindowText, paletteOld.color(QPalette::Active, QPalette::Window));
   paletteNew.setColor(QPalette::Active, QPalette::Window, paletteOld.color(QPalette::Active, QPalette::WindowText));

   connect( timer, SIGNAL(timeout()), this, SLOT(subtractOneSecond()) );
   connect( flashTimer, SIGNAL(timeout()), this, SLOT(flash()) );
   connect( this, SIGNAL(timerDone()), this, SLOT(endTimer()) );
   connect( pushButton_set, SIGNAL(clicked()), this, SLOT(setTimer()) );
   connect( pushButton_startStop, SIGNAL(clicked()), this, SLOT(startStop()) );
   connect( pushButton_sound, SIGNAL(clicked()), this, SLOT(getSound()) );

   showChanges();
}
Example #7
0
	void Munition::update(unsigned long elapsed_millis) {
	
		if( isActive ){
			
			fly();
			double elapsed_seconds = elapsed_millis / (double)1000;
			_physics.step( elapsed_seconds);
			actualizeTimer( elapsed_seconds );
			
			if ( isEndTimer() ) {

				endTimer();

			}
		
		}
		else {

			// the ball is inactive so don't update 

		}
	}
Example #8
0
BitSplit::BitSplit()
{
    fontDb.addApplicationFont(":/fonts/OpenSans-Light.ttf");
    fontDb.addApplicationFont(":/fonts/OpenSans-Regular.ttf");
    exit = true;
    blockToggle = false;
    searchExisting = false;

    /* Timer setup*/
    guiUpdater  = new QTimer( this );
    guiUpdater->setInterval(25);

    syncAnimator  = new QTimer( this );
    syncAnimator->setInterval(75);

    /* Interface setup */
    fileInterface.debug = false;
    fileInterface.copyDirection = BothDirections;
    actionCreator.fileInterface = &fileInterface;
    smartMatch.fileInterface = &fileInterface;
    actionHandler.fileInterface = &fileInterface;
    updater.fileInterface = &fileInterface;

    /* Set up icons */
    remove  = new QIcon(":images/general/remove.png");

    done    = new QIcon(":images/table/tick.png");
    errorIcon   = new QIcon(":images/table/error.png");
    skip    = new QIcon(":images/table/skip.png");

    sync1   = new QIcon(":images/table/sync1.png");
    syncAnimation.append(sync1);
    sync2   = new QIcon(":images/table/sync2.png");
    syncAnimation.append(sync2);
    sync3   = new QIcon(":images/table/sync3.png");
    syncAnimation.append(sync3);
    sync4   = new QIcon(":images/table/sync4.png");
    syncAnimation.append(sync4);
    sync5   = new QIcon(":images/table/sync5.png");
    syncAnimation.append(sync5);
    sync6   = new QIcon(":images/table/sync6.png");
    syncAnimation.append(sync6);
    sync7   = new QIcon(":images/table/sync7.png");
    syncAnimation.append(sync7);
    sync8   = new QIcon(":images/table/sync8.png");
    syncAnimation.append(sync8);


    ui.setupUi( this );
    ui.runButton->setDisabled(true);

    /* Connect buttons to their dialogs */
    connect(ui.editSettingsButton,  SIGNAL(clicked()),  this,   SLOT(editSettings()));
    connect(ui.newProfileButton,    SIGNAL(clicked()),  this,   SLOT(newProfile()));


    /* Log Connections*/
    connect(ui.actionView_Log,  SIGNAL(triggered()),        this,       SLOT(showLog()));
    connect(ui.exitLog,         SIGNAL(clicked()),          this,       SLOT(showMain()));
    connect(&fileInterface,     SIGNAL(updateLog(QString)), ui.log,     SLOT(append(QString)));
    connect(ui.errorViewLog,    SIGNAL(clicked()),          this,       SLOT(showLog()));

    /* Top Bar connections*/
    connect(&fileInterface, SIGNAL(matchComplete()),            this,               SLOT(matchComplete()));
    connect(&fileInterface, SIGNAL(updateSingle(QString)),      ui.topBarSingle,    SLOT(setText(QString)));
    connect(&fileInterface, SIGNAL(updateTopMP(QString)),       ui.mp_top,          SLOT(setText(QString)));
    connect(&fileInterface, SIGNAL(updateBottomMP(QString)),    ui.mp_bottom,       SLOT(setText(QString)));
    connect(&fileInterface, SIGNAL(updateOperationMP(QString)), ui.mp_operation,    SLOT(setText(QString)));
    connect(guiUpdater,     SIGNAL(timeout()),                  &smartMatch,        SLOT(updateGuiLabels()));
    connect(&smartMatch,    SIGNAL(startTime()),                guiUpdater,         SLOT(start()));
    connect(&smartMatch,    SIGNAL(stopTime()),                 guiUpdater,         SLOT(stop()));
    connect(&smartMatch,    SIGNAL(setTopBarLineStack(int)),    this,               SLOT(setTopBarLineStack(int)));

    /* Unmatched files tree Connections */
    connect(ui.unmatchedTree,   SIGNAL(itemChanged(QTreeWidgetItem*,int)),  this,   SLOT(toggleTree(QTreeWidgetItem*,int)));
    connect(&fileInterface,     SIGNAL(updateFileTree(bool, QTreeWidgetItem *)), this, SLOT(insertTreeItem(bool, QTreeWidgetItem *)));
    connect(&fileInterface,     SIGNAL(pop()),                              this,   SLOT(popParent()));
    connect(&fileInterface,     SIGNAL(expandTree()), this, SLOT(expandTree()));

    /* Matched Table Connections */
    connect(&fileInterface, SIGNAL(insertMatchTableRow(QList<QTableWidgetItem*>*)), this, SLOT(insertMatchTableRow(QList<QTableWidgetItem*>*)));

    /* Action Table Connections*/
    connect(&fileInterface, SIGNAL(insertActionTableRow(QList<QTableWidgetItem*>*)), this, SLOT(insertActionTableRow(QList<QTableWidgetItem*>*)));

    /* Error connections */
    connect(&smartMatch,    SIGNAL(operationFailed()),  this, SLOT(error()));
    connect(&actionCreator,    SIGNAL(operationFailed()),  this, SLOT(error()));
    connect(&actionHandler,     SIGNAL(exception()), this, SLOT(error()));

    /* Developer Test Connections */
    connect(ui.actionDeveloper_Test, SIGNAL(triggered()), this, SLOT(runDeveloperTest()));
    connect(&smartMatch, SIGNAL(stopTestTime()), this, SLOT(endTimer()));

    /* Action Handler Connections */
    connect(&actionHandler, SIGNAL(updateProgress(int)),            ui.progressBar,         SLOT(setValue(int)));
    connect(&actionHandler, SIGNAL(updateActionLabel(QString)),     ui.actionLabel,         SLOT(setText(QString)));
    connect(&actionHandler, SIGNAL(updateSpeedLabel(QString)),      ui.speedLabel,          SLOT(setText(QString)));
    connect(&actionHandler, SIGNAL(updatePercentageLabel(QString)), ui.mp_busyIndicator,    SLOT(setText(QString)));
    connect(&actionHandler, SIGNAL(setComplete(int)),               this,                   SLOT(setDone(int)));
    connect(&actionHandler, SIGNAL(setSkipped(int)),                this,                   SLOT(setSkip(int)));
    connect(&actionHandler, SIGNAL(setError(int)),                  this,                   SLOT(setError(int)));
    connect(&actionHandler, SIGNAL(setInProgress(int)),             this,                   SLOT(setSync(int)));

    /* Updater Connections */
    connect(&updater,       SIGNAL(complete()),     this,   SLOT(updaterComplete()));

    /* General Connections & Button Stack Connections */
    connect(syncAnimator,           SIGNAL(timeout()),  this,   SLOT(showSync()));
    connect(ui.finishEditButton,    SIGNAL(clicked()),  this,   SLOT(createActions()));
    connect(&actionCreator,         SIGNAL(complete()), this,   SLOT(actionsComplete()));
    connect(ui.runButton,           SIGNAL(clicked()),  this,   SLOT(runActionHandler()));
    connect(ui.searchButton,        SIGNAL(clicked()),  this,   SLOT(searchForSync()));
    connect(&actionHandler,         SIGNAL(complete()), this,   SLOT(actionHandlerComplete()));

    /* General Setup*/
    frame = 0;
    currentAction = -1;
    actionHandler.table = ui.actionsTable;
    ui.mp_ProfileLabel->fontMetrics().width(ui.mp_ProfileLabel->text());
    createTrayIcon();
    setupTable();
    fileInterface.loadDatabase();
    recentProfiles = fileInterface.loadRecentProfiles();
    if(recentProfiles.size() > 0)
        showRecentProfiles();

}
Example #9
0
double millisSince(struct timespec *time) {
	return ((double)endTimer(time) / (NANOS_PER_SEC / 1000));
}
Example #10
0
void Stoper::stop()
{
	performanceCountEnd = endTimer();
	tm = performanceCountEnd.QuadPart - performanceCountStart.QuadPart;
}
Example #11
0
void test() {

	int rozmiaryTab[4] = {1000,2000,5000,10000};
	
	for (int i = 0, range = 25000; i < 2;i++, range = 3 * range) {
		
		double srednie[4];
		 for (int kolejny_rozm = 0; kolejny_rozm < 4; kolejny_rozm++) {
			
			int rozmiar = rozmiaryTab[kolejny_rozm];
			RandomInputGenerator gen = *(new RandomInputGenerator());
			gen.generate(rozmiar, range);
			int* data = gen.getData();

			LinkedList tab = *(new LinkedList());



			for (int i = 0; i < rozmiar; i++)
			{
				tab.push_back(*(data + i));
				/*if (i == rozmiar - 100)
					tab.push(50000);
				else
					tab.push(100000);*/
			}


			/*testy push_front*/

			double avg[10];

			srand(time(NULL));
			for (int i = 0; i < 10; i++) {

				double wyniki[100];

				LARGE_INTEGER countStart, countEnd;
				for (int i = 0; i < 100; i++) {

					int x = rand() % range;
					//tab.pop();
					//tab.push(x);
					//int index = rozmiar / 2;
					//tab.replace(index, x);
					//int index = rozmiar;
					//index = index - 100;
					//int value = tab.get(index);
					/*POMIAR*/
					countStart = startTimer();
					tab.push_front(x); //!!!!!!!!!!!!!!!!!!!!!!!!TESTOWANA FUNKCJA!!!!!!!!!!!!!!!!!!!!!!!!!!!!
					countEnd = endTimer();
					/*--------*/
					//tab.pop();
					tab.pop_front();
					//tab.put(index,x);
					//tab.removeIndex(index);
					/*obliczenie pojedynczego wyniku*/
					double result = countEnd.QuadPart - countStart.QuadPart;



					/*zapisanie wyniku do tablicy*/
					wyniki[i] = result;
					//delete &tab;
				}


				double suma = 0;
				for (int i = 0; i < 100;i++)
					suma += wyniki[i];
				suma = suma / 100;

				avg[i] = suma;

			}

			double suma = 0;
			for (int i = 0; i < 10;i++)
				suma += avg[i];
			suma = suma / 10;
			srednie[kolejny_rozm] = suma;
			
		}
		 /*-----------Utworzenie nazwy pliku-------------*/
		 std::fstream plik;
		 std::stringstream konwerter;
		 std::string buf;

		 std::string nazwa = "D:\\Piotrek\\Documents\\Uczelnia\\IV semestr\\SDiZO\\TESTY projekt 1\\srednieczasy_";



		 konwerter << range;
		 buf = konwerter.str();

		 nazwa.append("range");
		 nazwa.append(buf);
		 nazwa.append(".txt");

		 plik.open(nazwa, std::ios::out);
		 for (int i = 0; i < 4; i++)
			 plik << srednie[i] << ";";
		 plik.close();

	}

	
	
	//tab.saveToFile("D:\\Piotrek\\Documents\\Uczelnia\\IV semestr\\SDiZO\\TESTY projekt 1\\test_data.txt");
	return;
}
Example #12
0
int main()
{
	/*GenerateGraph g(5, 50);
	Operation a;
	a.readStructure("plik.txt");
	cout << endl;
	a.makeY();
	a.makeNeighborListPrim();
	a.printListPrim();
	a.makeNeighborListDijkstry();
	a.printListDjikstry();
	a.makeMatrixPrim();
	a.printMatrixPrim();
	a.makeMatrixDjistry();
	cout << endl;
	a.printMatrixDjikstry();
	a.primMatrix();
	a.printPrimM();
	a.primList();
	a.printPrimL();
	a.dijkstryL(a.startowy);
	a.dijkstryM(a.startowy);
*/


//-------------------------- teraz menu-------------------
	//MENU menu;
	//menu.MENU1();

//--------------------------testy---------------------------

	LARGE_INTEGER CountStart, CountEnd, freq, timeOperation;

	srand(time(NULL));

	int sekundadzielnik = 1000000;
	int ilerazy = 100;
	int g, ileW;
	string gdzie = "result.txt";

	fstream plik;
	plik.open(gdzie, ios::out | ios::trunc);


////---------------------testy dla prima na liœcie--------------------------
//	g = 25;
//
//	for (int a = 0; a < 4; a++)
//	{
//		ileW = 40;
//		for (int i = 0; i < 5; i++)
//		{
//			plik << "\n" << to_string(ileW) + " " << to_string(g) << "\n";
//			for (int j = 0; j < ilerazy; j++)
//			{
//				GenerateGraph gr(ileW, g);
//				Operation o;
//				o.readStructure("plik.txt");
//				o.makeY();
//				o.makeNeighborListPrim();
//				CountStart = startTimer();
//
//				o.primList();
//
//				CountEnd = endTimer();
//				timeOperation.QuadPart = CountEnd.QuadPart - CountStart.QuadPart;
//				QueryPerformanceFrequency(&freq);
//				double tm = ((double)timeOperation.QuadPart)*sekundadzielnik / freq.QuadPart;
//
//				std::string str = std::to_string(tm);
//				plik << str << " ";
//			}
//			ileW += 20;
//		}
//		g += 25;
//		if (g == 100)g--;
//	}
//plik.close();
////-----------------------

////---------------------testy dla prima na macierzy--------------------------
//g = 25;
//
//for (int a = 0; a < 4; a++)
//{
//	int ileW = 40;
//	for (int i = 0; i < 5; i++)
//	{
//		plik << "\n" << to_string(ileW) + " " << to_string(g) << "\n";
//		for (int j = 0; j < ilerazy; j++)
//		{
//			GenerateGraph gr(ileW, g);
//			Operation o;
//			o.readStructure("plik.txt");
//			o.makeY();
//			o.makeMatrixPrim();
//			CountStart = startTimer();
//
//			o.primMatrix();
//
//			CountEnd = endTimer();
//			timeOperation.QuadPart = CountEnd.QuadPart - CountStart.QuadPart;
//			QueryPerformanceFrequency(&freq);
//			double tm = ((double)timeOperation.QuadPart)*sekundadzielnik / freq.QuadPart;
//
//			std::string str = std::to_string(tm);
//			plik << str << " ";
//		}
//		ileW += 20;
//	}
//	g += 25;
//	if (g == 100)g--;
//}
//plik.close();
////-----------------------


////---------------------testy dla djikstry na liœcie--------------------------przestaw losowanie!!!!
//g = 25;
//
//for (int a = 0; a < 4; a++)
//{
//	int ileW = 40;
//	for (int i = 0; i < 5; i++)
//	{
//		plik << "\n" << to_string(ileW) + " " << to_string(g) << "\n";
//		for (int j = 0; j < ilerazy; j++)
//		{
//			GenerateGraph gr(ileW, g);
//			Operation o;
//			o.readStructure("plik.txt");
//			o.makeY();
//			o.makeNeighborListDijkstry();
//
//			CountStart = startTimer();
//
//			o.dijkstryL(o.startowy);
//
//			CountEnd = endTimer();
//			timeOperation.QuadPart = CountEnd.QuadPart - CountStart.QuadPart;
//			QueryPerformanceFrequency(&freq);
//			double tm = ((double)timeOperation.QuadPart)*sekundadzielnik / freq.QuadPart;
//
//			std::string str = std::to_string(tm);
//			plik << str << " ";
//		}
//		ileW += 20;
//	}
//	g += 25;
//	if (g == 100)g--;
//}
//plik.close();
//
//plik.close();
////-----------------------


//---------------------testy dla djikstry na macierzy--------------------------przestaw losowanie!!!!
g = 25;

for (int a = 0; a < 4; a++)
{
	int ileW = 40;
	for (int i = 0; i < 5; i++)
	{
		plik << "\n" << to_string(ileW) + " " << to_string(g) << "\n";
		for (int j = 0; j < ilerazy; j++)
		{
			GenerateGraph gr(ileW, g);
			Operation o;
			o.readStructure("plik.txt");
			o.makeY();
			o.makeMatrixDjistry();
			CountStart = startTimer();

			o.dijkstryM(0);

			CountEnd = endTimer();

			timeOperation.QuadPart = CountEnd.QuadPart - CountStart.QuadPart;
			QueryPerformanceFrequency(&freq);
			double tm = ((double)timeOperation.QuadPart)*sekundadzielnik / freq.QuadPart;

			std::string str = std::to_string(tm);
			plik << str << " ";
		}
		ileW += 20;
	}
	g += 25;
	if (g == 100)g--;
}
plik.close();
//-----------------------


	return 0;
}