How can I fix stuttering. Is it due to unoptimized code?

Hello again…

You can add some code to monitor these stutters:

I got carried away with above…

It can be as simple as

  • checking time between frames using millis()
  • if it is much greater than 1/60fps = 17 ms (rounded up to nearest int) display something using println() or flash screen colors.
  • println() every frame can also slows things down so only use this with an if()

If you just monitor frameRate there is some averaging:

Time between frames show the spikes.

:)