-
Wed 2021.03.10
'In this case if the diff is greater than 1000ms then the timer was delayed.'
Hugh,
I'm not sure I'm 100% with what is attmepted here, but as
getTime()
returns consecutive incrementing floating point values,http://www.espruino.com/Reference#l__global_getTime
'Return the current system time in Seconds (as a floating point number)'why not place one inside the setInterval() at L7 and print that to the console?
That should help narrow down if the perfCheck() loop functions as expected.
Haven't tested, but if less than 1000msec then they should toggle, e.g. L7 :: L15, and on a delay the console should just update each 1000msec e.g. L7 only. Also time stamping inside perfCheck() should also coincide with L7
Would setTimeout() as it fires just once be a better choice?
I do however have an odd performance issue with one of the Apps.
I have a compass app based on the Magnav code. I use the same compass code in Waypointer and Arrow. All of these compass apps start to run slow after a while and become unresponsive to BTN3 presses. I have been trying to track down the issue.
I am wondering if the following approach is an indicator of performance.
Set a timer for a known time
Record the time using getTime
Then check that the time against the expected time.
If all is good you would expect the timer to come in close to the expected number of milliseconds. In this case if the diff is greater than 1000ms then the timer was delayed.
Sometimes I am seeing this sort of output.
The above is a lucky example, it does not usually happen with the screen going off (I think that is cooincidence here). I can keep the screen on by pressing BTN3 before it goes off and sometimes I will see this.
If feels like something else is grabbing resource.
Kind of need the equivalent of the unix uptime command to see how loaded the CPU is.