but the Garmin underestimated my elevation gain by 300 ft? Also, my heart rate was up there(161 bpm/max 176), I guess a higher cadence does that.
AFAIC all GPS trackers 'guesstimate' elevation. Of any three Garmin 510's and 520's on a ride they will all disagree with each other. On a 5000' ride over 70 miles the differences can be in the 20%+ range. Accuracy and repeatability seem to be lacking. I have no clue 'why' this happens, but I think part of it is induced by the inaccurate temperature sensor used to correct the barometer.
Read all of the material published by Brian Toone, ultra-marathon cyclist, RAAM competitor and state USCF.USAC road champion. He rides with three or four Garmin's and an iNewton. He claims the mounting position, device attitude (leading edge up as opposed to horizontal, etc.) affects elevation readings.
Also, study the writings and reviews of DC Rainmaker. His insights are invaluable when it comes to GPS devices and power meters.
Lastly, compare your Garmin readings to point-by-point elevation data from MapMyRide, Ride With GPS, etc. When creating your route mate click on every intersection and every cross road to utilize known GPS way points. This will get you in the ball park.
I bought my first GPS device, a pretty nice Cateye Stealth 50, thinking the GPS data would be an accurate number that correlated almost identically to the data from my friends' devices. Wrong! The resolution, repeatability and absolute accuracy of the cycling GPS computers is not all that great. It does give us a decent comparative or relative attribute to train with.