Ever had your arduino IDE take many many minutes to compile even simple sketches? Well it may not be totally it’s fault. Yes, the arduino IDE isn’t the most efficient but sketches that should take less than 20 seconds to compile are taking about 3 minutes!
The Source of the problem: Your Anti-Virus! Yes, your anti-virus plays a big role in the time it takes to compile these sketches, not because it does any compiling work ofcourse, but due to the “Real-time scanning” that they have. These constantly check the files that are being used (like header files included in your sketch) and the compiled files that are being made, and the arduino IDE makes quite a lot of them before linking them all into one. So checking every file as its being used and made takes a lot of time, slowing your compilations down by a large factor.
The Solution: The good news is, anti-virus softwares also have an real-time scanning exception list (not the normal full scan exception list) and the files/folders added to this list will be exempt from real-time scanning. So by adding the path of your Arduino executable folder and the libraries folder, you can more than quarter your compilation times! Adding your sketch directory may also help.
Note: It is not recommended to disable your real-time scanning completely as it will definitely weaken the security of your device.
Moreover, if the libraries and the arduino exe folder are on the same hard drive, it will definitely help reduce compilation times as the data can be read and written to, faster.
WARNING: Adding other unknown files/directories that you don’t definitely trust, or those whose content is got from external sources (like the downloads folder where files from the internet are downloaded and saved) can severely weaken the security of your system as the files in the exception list will not be checked in real-time by your anti-virus.
Hope you can get rid of frustratingly slow sketch compilations for good! Happy compiling.