If you compile a file for the first time. Everything is re-compiled.
This happends too if you save a *.ino-file as "save to ..." with a new filename.
If you only modify the code but keep the filename then precompiled files are used.
All ESP32's use FreeRTOS as the framework, which is a lot of code. This is the reason
why it takes longer for a ESP32-project to compile than a Arduino-Uno-project.
In the compiling-process there are millions of steps to do. And as there are so many steps and so many lines of code calculation-speed of your computer has a significant effect.
I compiled a ESP32-project on an old Terra mini-PC. This computer is optimised for low-power-consumption. First compile took 12 minutes. second compile 5 minutes.
If I compile the exact same code on a
Lenovo Thinkpad T480 first compile 4 minutes, second compile 1 minute
I did this with Arduino-IDE Version 1.8.19.
The Arduino-IDE Version 2.X had a lot of performance-problems at the beginning.
And there is still one thing that keeps me away from using Version 2.X.
The new IDE Version 2.X.Y has a fundamental problem with the serial monitor
In Arduino-IDE-Version 2.X.Y the serial monitor is crippled .
You can't make effective use of it.
This is a problem that has been discussed for more than a half year now, but the Arduino-IDE-development-team refuses to work on a solution.
This means your solution is to work with Arduino-IDE 1.8.19. There is a possability to have Arduino-IDE 1.8.19 on the same computer without interfering with IDE 2.X.Y.
This is done through making the Arduino-IDE Version 1.8.19 as a portable version. The portable version 1.8.19 does not interfere with a Arduino-IDE 2.X.Y-Installation.
Arduino-IDE Version 1.8.19 does have less bells and whistles than IDE 2.X.Y but compiles and uploads just the same. And serial printing works like a charm.
You can read in this tutorial how to install Arduino-IDE 1.8.19 as portable version
tutorial how to install Arduino-IDE Version 1.8.19 as portable
@ptillisch anything new about improving the serial monitor in version 2.X?