To those of you who have antimalware / antivirus issues or slow compiles for sketches.
There is usually an option in those programs to whitelist / exclude files and folders.
Slow compiles under Windows and may apply to other OS if you have similar software.
Add the Arduino directories to your antivirus / anti malware / other security exclusions.
So that would be at least two of the following.
C:\Program Files (x86)\Arduino
C:\Users\yourname\AppData\Local\Arduino15 depends on IDE
C:\Users\yourname\AppData\Roaming\Arduino15 depends on IDE
If you have your sketches set up in a different location it’s also worth adding that directory to the exclusions also.
Additionally if you also use the online IDE “CREATE” the following directories.
If you have installed to a different drive swap the drive letter as needed.
If you also have an unzipped IDE installed that path should also be added to exclusions
Some third party firewalls also cause issues and again look to exclude the above folders from that.
The following should also be allowed through your firewall
"Java(TM) Platform SE binary"
Depending on how your network is set up you may have to allow Home/Work (Private) and also Public.
If you have CREATE installed ensure that is also allowed through the firewall
Beware that not all "antimalware" software is actually what it says. There are rogue versions out there so ensure it is a "reputable" brand and not some obscure name.