I've had at least 2 Savage 9317s, 1 x CZ452, 1 Marlin 917=all heavy barrels, all 17HMRs. The CZ shot one of the tightest groups I've ever achieved with a rimfire, under 3/8" @ 100 yards using Hornady 20gr. HPs. And yes, the only gun I honestly regret selling. The only one left is the Marlin 917, and it has an aftermarket Rifle Basix trigger in it. The only time I shoot it is when I'm either gopher shooting out west, or, practicing for gopher shooting out west. lol I get no pleasure out of target shooting with it if I'm being honest, but the gun will print sub-MOA groups 2/3 of the time if I'm doing my part....and I've managed 1/2 groups with it a few times. (Felt like luck, but who knows) I am inclined to agree with prairieguy when it comes to ammo, but will say this-17HMR is an inherently "accurate" caliber in my experience, and most HMRs I've shot tend to print around 1" @ 100 no matter who is shooting it. Wind can be problematic with such light bullets, but they have some speed on their side. I think with this caliber, if accuracy really matters..buy the best gun you can afford, Hornady 17 and 20gr. ammo, all CCI ammo types you can get your hands on...and test it out. Unlike 22LR, you'll be "limited" to maybe 5+ ammo types, but chances are (if the gun is decent) that one or more will shoot an inch or under.
22LR is a different story. More options for guns, WAY more options for ammo, etc. Better ammo will shoot better, and you have a gun that will make the most of it, some caviar-grade ammo types are capable of impressive groups. I have a bit of a mental block when it comes to really buying the expensive stuff, I top-out around $13/50 with SK Rifle Match.

With that said, I've flirted with ammo in the $20-$30/50 range...and well, the groups shrink fast=as one would expect.
So, what to get? Well, if I was confident it would be accurate...a Savage B17-FV-SR would be awfully tempting. I had a Mark II FV-SR (22LR) that was not accurate, but boy..what a handy-sized rifle...a little chunky/beefy thing. I really liked it. If this was my first foray into rimfire, I wanted an HMR and had the budget, for sure...either a CZ452 series or a Tikka. Probably a Tikka if I'm being honest, but as mentioned earlier...my 452 Varmint was a heck of a shooter.