acid-drop

- Hacking the planet from a LilyGo T-Deck using custom firmware
git clone git://git.acid.vegas/acid-drop.git
Log | Files | Refs | Archive | README | LICENSE

README.md (4143B)

      1 # AutoBenchmark
      2 
      3 This sketch measures the amount of time consumed by the `AceButton::check()`
      4 method when processing various button events. It uses a special
      5 `ProfilingButtonConfig` object that allows the program to inject button events
      6 into the library. The profiling numbers come from activating the `TimingStats`
      7 object that has been instrumented into the `AceButton::check()` method.
      8 
      9 Note that `ProfilingButtonConfig` class generates synthetic button events,
     10 bypassing the actual `digitalRead()` function. The `digitalRead()` function on
     11 an Arduino AVR platform (UNO, Nano, etc) is
     12 [known to be slow](https://forum.arduino.cc/index.php?topic=337578)
     13 which will add to the timing values in actual usage.
     14 The [digitalWriteFast library](https://github.com/NicksonYap/digitalWriteFast)
     15 might be an alternative if speed is critical.
     16 
     17 ## Benchmark Results
     18 
     19 In all of the tests, the **min** time for the "idle" case is larger than any of
     20 the other button events. This is because when a button event occurs, the
     21 `AceButton::checkDebounced()` method returns immediately until the debouncing
     22 time is over which brings down the minimum time. No debouncing is done in the
     23 "idle" case so the minimum code path takes more CPU cycles.
     24 
     25 All times are in microseconds. The "samples" column is the number of
     26 `TimingStats::update()` calls that were made.
     27 
     28 ### Arduino Nano
     29 
     30 * 16MHz ATmega328P
     31 
     32 ```
     33 ------------------------+-------------+---------+
     34 button event            | min/avg/max | samples |
     35 ------------------------+-------------+---------+
     36 idle                    |  12/ 13/ 20 | 1934    |
     37 press/release           |   8/ 14/ 20 | 1925    |
     38 click                   |   8/ 14/ 24 | 1925    |
     39 double click            |   8/ 13/ 24 | 1925    |
     40 long press/repeat press |   8/ 15/ 24 | 1927    |
     41 ------------------------+-------------+---------+
     42 ```
     43 
     44 ### Arduino Pro Micro
     45 
     46 * 16MHz ATmega32U4
     47 
     48 ```
     49 ------------------------+-------------+---------+
     50 button event            | min/avg/max | samples |
     51 ------------------------+-------------+---------+
     52 idle                    |  12/ 13/ 24 | 1935    |
     53 press/release           |   8/ 14/ 24 | 1928    |
     54 click                   |   8/ 13/ 24 | 1928    |
     55 double click            |   8/ 13/ 24 | 1926    |
     56 long press/repeat press |   8/ 15/ 28 | 1928    |
     57 ------------------------+-------------+---------+
     58 ```
     59 
     60 ### Teensy 3.2
     61 
     62 * 96 MHz ARM Cortex-M4
     63 
     64 ```
     65 ------------------------+-------------+---------+
     66 button event            | min/avg/max | samples |
     67 ------------------------+-------------+---------+
     68 idle                    |   3/  3/  5 | 1985    |
     69 press/release           |   1/  3/  6 | 1983    |
     70 click                   |   1/  3/  6 | 1984    |
     71 double click            |   1/  3/  6 | 1984    |
     72 long press/repeat press |   1/  3/  6 | 1983    |
     73 ------------------------+-------------+---------+
     74 ```
     75 
     76 ### NodeMCU 1.0 clone
     77 
     78 * 80MHz ESP8266
     79 
     80 ```
     81 ------------------------+-------------+---------+
     82 button event            | min/avg/max | samples |
     83 ------------------------+-------------+---------+
     84 idle                    |   7/  8/ 24 | 1922    |
     85 press/release           |   6/  8/ 53 | 1919    |
     86 click                   |   6/  8/ 50 | 1920    |
     87 double click            |   6/  8/ 67 | 1910    |
     88 long press/repeat press |   6/  9/ 60 | 1894    |
     89 ------------------------+-------------+---------+
     90 ```
     91 
     92 The large **max** times for "double click" and "long press" seem to be
     93 reproducible. I have not researched this but my speculation is that the system
     94 WiFi code interrupts the `AceButton::check()` method right when the "double
     95 click" and "long press" samples are taken, causing the extra latency.
     96 
     97 ### ESP32-01 Dev Board
     98 
     99 * 240 MHz Tensilica LX6
    100 
    101 ```
    102 ------------------------+-------------+---------+
    103 button event            | min/avg/max | samples |
    104 ------------------------+-------------+---------+
    105 idle                    |   3/  3/  3 | 2002    |
    106 press/release           |   2/  2/  8 | 2002    |
    107 click                   |   2/  2/  7 | 2002    |
    108 double click            |   2/  2/  4 | 2002    |
    109 long press/repeat press |   2/  2/  4 | 2002    |
    110 ------------------------+-------------+---------+
    111 ```