Looking for a better frequency counter library

RandallR:
But isn't timer0 is used for delay() and millis() and other Arduino functions. I am hesitant to use the timers directly because they are used for other Arduino functions like tone() and analogWrite().

Yes it is, but if you know what you are trying to achieve you can choose whether you want the extra accuracy. For example:

 // stop Timer 0 interrupts from throwing the count out
  byte oldTCCR0A = TCCR0A;
  byte oldTCCR0B = TCCR0B;
  TCCR0A = 0;    // stop timer 0
  TCCR0B = 0;    
  
  startCounting (500);  // how many mS to count for

  while (!counterReady) 
     { }  // loop until count over
  
  // restart timer 0
  TCCR0A = oldTCCR0A;
  TCCR0B = oldTCCR0B;

Here we just turn off timer 0 during the frequency count. So the millis figure will be out by the duration of the counting. You may not care about that.

Again to improve accuracy I increased the sample size.

There is a trade-off between the two methods I mentioned on my web page. One measures the period (by measuring the time for exactly one pulse change) and the other measures the frequency (by counting).

The period one is better suited to lower frequencies, because you get a higher-resolution result. Plus it is fast, even for, say, 50 Hz. It would take 1/50th of a second to work out 50 Hz.

The frequency counter is better suited to higher frequencies, because you get a higher count. So for example, to measure 5 MHz you probably want to count, rather than measure the period. But for 50 Hz you probably want to measure the period, rather than count.