analogRead messes up my frequency counter function

So do you think this delay is what's throwing off my frequency counter code? I originally wrote the frequency counter code in the main loop, but I was encountering this issue so I thought I'd try a for loop. I figured if I put the code into a for loop, and called it in a separate function it would run exclusively and avoid any time delays created by other code... but my results are identical. My frequency count is thrown off by -8Hz. I'm assuming some sort of delay occurs during the loop causing it to miss cycles of my test frequency when I add that function.

As for

pinMode(5, INPUT);

I'm using analog pin 5 for my voltage test. Maybe the pin initialization isn't necessary, but I don't think this is related to my issue.