A = get the time. ...spend a while doing stuff... B = get the time ...loop for next frame... C = get the time time spent doing stuff previously = C-B (wrong) ...spend a while doing stuff... etc
You really want to be measuring the time from the start of frame#1 to the start of frame#2.
A = get the time. ...spend a while doing stuff... ...loop for next frame... B = get the time time spent doing stuff previously = B-A ...spend a while doing stuff... etc