Arduino code for other boards may require additional layers for compatibility. New processors with advanced features may lack the simplicity of the ATmega328P.
I will test this freqCount Library that is mentioned in the post.
Sketch uses 936 bytes (2%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables.
Blink on an ESP32;
Sketch uses 237117 bytes (18%) of program storage space. Maximum is 1310720 bytes.
Global variables use 21048 bytes (6%) of dynamic memory, leaving 306632 bytes for local variables.