bxparks / AceButton

An adjustable, compact, event-driven button library for Arduino that debounces and dispatches events to a user-defined event handler.
MIT License
385 stars 37 forks source link

add internal stats variable to track amount of CPU time taken for certain code paths #9

Closed bxparks closed 6 years ago

bxparks commented 6 years ago

The StopWatch.ino example code gives the CPU time taken by AceButton.check() when nothing is happening. It'd be nice to get information about how much CPU time it takes to handle certain events, like Click and DoubleClick. I think the only way to get that information is to insert stats variables into the AceButton class itself. I'd want something like average, min, max and the ability to reset the stats periodically, say every 5 seconds. I think one way to reduce the runtime cost of the stats gathering, and reduce static memory is to inject the "stats" object into AceButton and only do the calculation if the stats object is not null. So 2 more extra bytes on an 8-bit AVR.