ESP32 Takes A While To Compile And Doesnt Function Properly

Recently i purchased an ESP32 module for a WiFi project I'm working on. Once I got it though, I realized two things; it takes unusually long to compile code, and it refuses to connect to WiFi. Here is my code:

#include <WiFi.h>
#include<HTTPClient.h>

const char* ssid = "CGSEN12AG";
const char* password = "ASDF123!!";

void setup() {

Serial.begin(115200);
delay(4000);

WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi..");
}

Serial.println("Connected to the WiFi network");

}

void loop() {

}

I've tried adding Arduino15 to the exclusion list on my antivirus software, I've added https://dl.espressif.com/dl/package_esp32_index.json to the preferences' board managers urls, I've downloaded the drivers and the ESP32 libraries, and yet I still have to wait a few minutes for the code to compile and upload, and even if it does i get this message:

The selected serial port failed to execute script esptool

or

The program does upload but then shuts down

Have you went to Tools|Core Debug Level and selected Debug. I am going to guess you will see some errors in which case you'd want to know about this link Fatal Errors - ESP32 - — ESP-IDF Programming Guide latest documentation.

Thank you so much for responding. I don't know what it was but once I restarted my computer the code did end up working. I'm still having trouble with it taking a few minutes to compile but if that's the worst of my worries then I'd say the problem is solved.