In the simulator, the times showed the same, which I didn't find surprising, but my experience programming data fields in the past was that the data in the info passed to compute doesn't match the built-in data fields -- mostly it seems like a custom data field gets the data a bit later. So I'd see, for example, average pace derived from activity info lag the built-in data field pace.
When I tried showing system time vs activity info time from compute on my vivoactive, however, what I saw was that the compute time was about a quarter of a second greater than the system elapsed time. The code I have is like the below. I display the two times side-by-side in the onUpdate(dc) method:
hidden var _M_previous;
hidden var _M_elapsed;
hidden var _M_paused;
hidden var _M_stopped;
hidden var computeElapsed;
function updateElapsed() {
var current = Sys.getTimer();
if (!_M_paused && !_M_stopped && _M_previous != null) {
_M_elapsed += current - _M_previous;
}
_M_previous = current;
}
function compute(info) {
updateElapsed();
computeElapsed = 0;
if (info.elapsedTime) {
computeElapsed = info.elapsedTime;
}
}
I'm really quite puzzled about the relationship between system elapsed time, and elapsed time in activity info. Although having onTimerLap is a massive plus compared to what was available at the end of 2015 when I had to guess when new laps began, it still seems non-trivial to accurately calculate your own lap pace for example, i.e. to match the lap pace the built-in field shows.
Can anyone explain the relationship between system elapsed time you get in onTimerLap, for example, and elapsedTime in compute? I'm also interested whether or not there is a lag between built-in data fields and custom data fields.
(Another thing I noticed was that the activity info elapsed time doesn't take account of any pauses. Although this is something I can live.)