inf0rmatix / reliable_interval_timer

A timer running a callback in a specified interval
BSD 3-Clause "New" or "Revised" License
7 stars 2 forks source link

High CPU usage #7

Open eirikskogoy opened 4 months ago

eirikskogoy commented 4 months ago

Hi :) Experience very high CPU usage when using this, has anyone else experienced the same?

inf0rmatix commented 4 months ago

Thanks for the info, did you verify this in a new flutter project using only this package?

flyte commented 3 months ago

I also get very high CPU usage when using this timer. I thought it was because my interval was 10ms but it's the same at 100ms.

I imagine it's because it uses a Timer with a period of 500 microseconds internally? Perhaps that could be configurable if we don't need that level of precision?

eirikskogoy commented 3 months ago

Thanks for the info, did you verify this in a new flutter project using only this package?

Sorry for not replying before now. I didn't test it a separate project. But removing it and using the standard Timer.periodic lowered the cpu usage from typical 80% to 5%

inf0rmatix commented 1 month ago

^^"

Please excuse the long delay, have been very busy lateley.

Most likely this issue is connected to the underlying timer ticking as frequent as possible to achieve maximum precision.

Honestly I think this was a oversight of mine back then.

Maybe using the standard timer is better, if you really need super mega ultra precision this solution here might be good, as long as the duration is not too long and you are not using it constantly.

:)

inf0rmatix commented 1 month ago

I also get very high CPU usage when using this timer. I thought it was because my interval was 10ms but it's the same at 100ms.

I imagine it's because it uses a Timer with a period of 500 microseconds internally? Perhaps that could be configurable if we don't need that level of precision?

I'll happily review, merge and update the package if you could kindly provide the required changes in a PR :)