I always heard that with a 22 rimfire, that about 14 inches was about it for speed, guess that is why bloop tubes were added to some fancy rifles.
Folks are right about complexity on this query. Seems to never end variables in the equation of result.
Longer barrels can be milder to the user to use, all things the same; shorter barrels are easy to carry, but can suffer noise, blast etc.
one thing to remember about barrel length, is that your range to the target is usually shorter.
Rick W.