This is my problem, I've been trying to code in C++ in VSCode, so I followed the VSCode tutorial and installed Mingw-w64 via MSYS2 and everything works. But when I compile the file and execute the exe file in VSCode terminal, it's so slow, so I made a test speed with Python and Python wins. There has to be something wrong. This are my results.
import time
start = time.time()
for i in range(1000):
for e in range(i):
if (e*i)%2 == 0:
print(e*i)
end = time.time()
print(end - start)
This is a random program to test the speed in Python and it takes 74 seconds in VSCode terminal and 16 seconds in the Command Prompt (I don't know why the VSCode terminal is that slow)
#include <iostream>
#include <chrono>
using namespace std::chrono;
using namespace std;
int main(){
auto start = high_resolution_clock::now();
for (int i=0; i<1000; i++){
for (int e=0; e<i; e++){
if ((e*i) % 2 == 0){
cout<<e*i<<endl;
}
}
}
auto stop = high_resolution_clock::now();
auto duration = duration_cast<microseconds>(stop - start);
cout << duration.count() << endl;
}
This is the same program written in C++, which would have to be faster, but when I compile it and execute the exe file, it takes over 2 minutes to run in VSCode terminal and 60 seconds in the Command Prompt. Where is the problem? In the compiler? In VSCode? Why is the program faster in the Command Prompt and Why is Python faster?