I'm pretty new to C++ and want just to test how fast C++ can do following job:
Just create a vector with 100 Objectc of Object-Point (x,y-Coordinate) and move it to another vector. Repeat this k-times. (in this code it is 1000000-times - int Iterator).
Well since im very new to C++, do you see a better way to do it, or did i miss something?
Im running on Windows.
#include "Main.h"
#include "Point.h"
#include <iostream>
#include <vector>
#include <chrono>
int main() {
auto start = std::chrono::high_resolution_clock::now();
int Constant = 10;
int Iterator = 1000000;
std::vector<Point>* tour = new std::vector<Point>();
std::vector<Point>* actions = new std::vector<Point>();
for (int k=0; k<Iterator; k++) {
for (int i=0; i<Constant; i++) {
for (int j=0; j<Constant; j++) {
Point *p = new Point((i * 10) + j,i + 1, j + 1);
actions->push_back(*p);
}
}
while(!actions->empty()) {
tour->push_back(actions->at(0));
actions->erase(actions->begin());
}
actions->clear();
tour->clear();
}
auto finish = std::chrono::high_resolution_clock::now();
std::cout << std::chrono::duration_cast<std::chrono::nanoseconds>(finish-start).count() << std::endl;
}