<filename>examples/MemoryBenchmark/generate_readme.py
#!/usr/bin/python3
#
# Python script that regenerates the README.md from the embedded template. Uses
# ./generate_table.awk to regenerate the ASCII tables from the various *.txt
# files.

from subprocess import check_output

nano_results = check_output(
    "./generate_table.awk < nano.txt", shell=True, text=True)
micro_results = check_output(
    "./generate_table.awk < micro.txt", shell=True, text=True)
samd_results = check_output(
    "./generate_table.awk < samd.txt", shell=True, text=True)
stm32_results = check_output(
    "./generate_table.awk < stm32.txt", shell=True, text=True)
esp8266_results = check_output(
    "./generate_table.awk < esp8266.txt", shell=True, text=True)
esp32_results = check_output(
    "./generate_table.awk < esp32.txt", shell=True, text=True)
teensy32_results = check_output(
    "./generate_table.awk < teensy32.txt", shell=True, text=True)

print(f"""\
# Memory Benchmark

The `MemoryBenchmark.ino` was compiled with each `FEATURE_*` and the flash
memory and static RAM sizes were recorded. The `FEATURE_BASELINE` selection is
the baseline, and its memory usage numbers are subtracted from the subsequent
`FEATURE_*` memory usage.

**Version**: AceSorting v1.0.0

**DO NOT EDIT**: This file was auto-generated using `make README.md`.

## How to Regenerate

To regenerate this README.md:

```
$ make clean_benchmarks
$ make benchmarks
$ make README.md
```

The `make benchmarks` target uses `collect.sh` script which calls `auniter.sh`
(https://github.com/bxparks/AUniter) to invoke the Arduino IDE programmatically.
It produces a `*.txt` file with the flash and ram usage information (e.g.
`nano.txt`).

The `make README.md` command calls the `generated_readme.py` Python script which
generates this `README.md` file. The ASCII tables below are generated by the
`generate_table.awk` script, which takes each `*.txt` file and converts it to an
ASCII table.

## Library Size Changes

**v0.1**

* Initial version.
* The memory usage for C-library `qsort()` is suspiciously low on the ESP32,
  only 88 bytes, compared to 800-1400 bytes for other platforms. I think this
  indicates that the `qsort()` function is already compiled into the ESP32
  runtime library.

**v0.3**

* Add 3-argument version of sorting functions to pass in a comparison predicate,
  and route the 2-argument version into the 3-argument version.
* Usually no difference in flash size, as the compiler seems to be able to
  inline the lambda expression. In fact, some actually got a few bytes smaller.

**v1.0.0**
* Some minor changes to total flash consumption due to upgrading the
  tool chain for SAMD21, ESP8266 and TeensyDuino. The delta flash consumption
  of each algorithm did not change much.

## Arduino Nano

* 16MHz ATmega328P
* Arduino IDE 1.8.16, Arduino CLI 0.19.2
* Arduino AVR Boards 1.8.3

```
{nano_results}
```

## Sparkfun Pro Micro

* 16 MHz ATmega32U4
* Arduino 1.8.16, Arduino CLI 0.19.2
* SparkFun AVR Boards 1.1.13

```
{micro_results}
```

## SAMD21 M0 Mini

* 48 MHz ARM Cortex-M0+
* Arduino 1.8.16, Arduino CLI 0.19.2
* Sparkfun SAMD Boards 1.8.4

```
{samd_results}
```

(SAMD compiler does not produce RAM usage numbers.)

## STM32 Blue Pill

* STM32F103C8, 72 MHz ARM Cortex-M3
* Arduino 1.8.16, Arduino CLI 0.19.2
* STM32duino 2.0.0

```
{stm32_results}
```

## ESP8266

* NodeMCU 1.0, 80MHz ESP8266
* Arduino 1.8.16, Arduino CLI 0.19.2
* ESP8266 Boards 3.0.2

```
{esp8266_results}
```

## ESP32

* ESP32-01 Dev Board, 240 MHz Tensilica LX6
* Arduino 1.8.16, Arduino CLI 0.19.2
* ESP32 Boards 1.0.6

```
{esp32_results}
```

RAM usage remains constant as more objects are created, which indicates that an
initial pool of a certain minimum size is created regardless of the actual RAM
usage by objects.

## Teensy 3.2

* 96 MHz ARM Cortex-M4
* Arduino 1.8.16, Arduino CLI 0.19.2
* Teensyduino 1.55

```
{teensy32_results}
```
""")

<filename>examples/MemoryBenchmark/generate_readme.py
#!/usr/bin/python3
#
# Python script that regenerates the README.md from the embedded template. Uses
# ./generate_table.awk to regenerate the ASCII tables from the various *.txt
# files.

from subprocess import check_output

nano_results = check_output(
    "./generate_table.awk < nano.txt", shell=True, text=True)
micro_results = check_output(
    "./generate_table.awk < micro.txt", shell=True, text=True)
samd_results = check_output(
    "./generate_table.awk < samd.txt", shell=True, text=True)
stm32_results = check_output(
    "./generate_table.awk < stm32.txt", shell=True, text=True)
esp8266_results = check_output(
    "./generate_table.awk < esp8266.txt", shell=True, text=True)
esp32_results = check_output(
    "./generate_table.awk < esp32.txt", shell=True, text=True)
teensy32_results = check_output(
    "./generate_table.awk < teensy32.txt", shell=True, text=True)

print(f"""\
# Memory Benchmark

The `MemoryBenchmark.ino` was compiled with each `FEATURE_*` and the flash
memory and static RAM sizes were recorded. The `FEATURE_BASELINE` selection is
the baseline, and its memory usage numbers are subtracted from the subsequent
`FEATURE_*` memory usage.

**Version**: AceSorting v1.0.0

**DO NOT EDIT**: This file was auto-generated using `make README.md`.

## How to Regenerate

To regenerate this README.md:

```
$ make clean_benchmarks
$ make benchmarks
$ make README.md
```

The `make benchmarks` target uses `collect.sh` script which calls `auniter.sh`
(https://github.com/bxparks/AUniter) to invoke the Arduino IDE programmatically.
It produces a `*.txt` file with the flash and ram usage information (e.g.
`nano.txt`).

The `make README.md` command calls the `generated_readme.py` Python script which
generates this `README.md` file. The ASCII tables below are generated by the
`generate_table.awk` script, which takes each `*.txt` file and converts it to an
ASCII table.

## Library Size Changes

**v0.1**

* Initial version.
* The memory usage for C-library `qsort()` is suspiciously low on the ESP32,
  only 88 bytes, compared to 800-1400 bytes for other platforms. I think this
  indicates that the `qsort()` function is already compiled into the ESP32
  runtime library.

**v0.3**

* Add 3-argument version of sorting functions to pass in a comparison predicate,
  and route the 2-argument version into the 3-argument version.
* Usually no difference in flash size, as the compiler seems to be able to
  inline the lambda expression. In fact, some actually got a few bytes smaller.

**v1.0.0**
* Some minor changes to total flash consumption due to upgrading the
  tool chain for SAMD21, ESP8266 and TeensyDuino. The delta flash consumption
  of each algorithm did not change much.

## Arduino Nano

* 16MHz ATmega328P
* Arduino IDE 1.8.16, Arduino CLI 0.19.2
* Arduino AVR Boards 1.8.3

```
{nano_results}
```

## Sparkfun Pro Micro

* 16 MHz ATmega32U4
* Arduino 1.8.16, Arduino CLI 0.19.2
* SparkFun AVR Boards 1.1.13

```
{micro_results}
```

## SAMD21 M0 Mini

* 48 MHz ARM Cortex-M0+
* Arduino 1.8.16, Arduino CLI 0.19.2
* Sparkfun SAMD Boards 1.8.4

```
{samd_results}
```

(SAMD compiler does not produce RAM usage numbers.)

## STM32 Blue Pill

* STM32F103C8, 72 MHz ARM Cortex-M3
* Arduino 1.8.16, Arduino CLI 0.19.2
* STM32duino 2.0.0

```
{stm32_results}
```

## ESP8266

* NodeMCU 1.0, 80MHz ESP8266
* Arduino 1.8.16, Arduino CLI 0.19.2
* ESP8266 Boards 3.0.2

```
{esp8266_results}
```

## ESP32

* ESP32-01 Dev Board, 240 MHz Tensilica LX6
* Arduino 1.8.16, Arduino CLI 0.19.2
* ESP32 Boards 1.0.6

```
{esp32_results}
```

RAM usage remains constant as more objects are created, which indicates that an
initial pool of a certain minimum size is created regardless of the actual RAM
usage by objects.

## Teensy 3.2

* 96 MHz ARM Cortex-M4
* Arduino 1.8.16, Arduino CLI 0.19.2
* Teensyduino 1.55

```
{teensy32_results}
```
""")

#!/usr/bin/python3 # # Python script that regenerates the README.md from the embedded template. Uses # ./generate_table.awk to regenerate the ASCII tables from the various *.txt # files. \ # Memory Benchmark  The `MemoryBenchmark.ino` was compiled with each `FEATURE_*` and the flash memory and static RAM sizes were recorded. The `FEATURE_BASELINE` selection is the baseline, and its memory usage numbers are subtracted from the subsequent `FEATURE_*` memory usage.  **Version**: AceSorting v1.0.0  **DO NOT EDIT**: This file was auto-generated using `make README.md`.  ## How to Regenerate  To regenerate this README.md:  ``` $ make clean_benchmarks $ make benchmarks $ make README.md ```  The `make benchmarks` target uses `collect.sh` script which calls `auniter.sh` (https://github.com/bxparks/AUniter) to invoke the Arduino IDE programmatically. It produces a `*.txt` file with the flash and ram usage information (e.g. `nano.txt`).  The `make README.md` command calls the `generated_readme.py` Python script which generates this `README.md` file. The ASCII tables below are generated by the `generate_table.awk` script, which takes each `*.txt` file and converts it to an ASCII table.  ## Library Size Changes  **v0.1**  * Initial version. * The memory usage for C-library `qsort()` is suspiciously low on the ESP32,   only 88 bytes, compared to 800-1400 bytes for other platforms. I think this   indicates that the `qsort()` function is already compiled into the ESP32   runtime library.  **v0.3**  * Add 3-argument version of sorting functions to pass in a comparison predicate,   and route the 2-argument version into the 3-argument version. * Usually no difference in flash size, as the compiler seems to be able to   inline the lambda expression. In fact, some actually got a few bytes smaller.  **v1.0.0** * Some minor changes to total flash consumption due to upgrading the   tool chain for SAMD21, ESP8266 and TeensyDuino. The delta flash consumption   of each algorithm did not change much.  ## Arduino Nano  * 16MHz ATmega328P * Arduino IDE 1.8.16, Arduino CLI 0.19.2 * Arduino AVR Boards 1.8.3  ``` {nano_results} ```  ## Sparkfun Pro Micro  * 16 MHz ATmega32U4 * Arduino 1.8.16, Arduino CLI 0.19.2 * SparkFun AVR Boards 1.1.13  ``` {micro_results} ```  ## SAMD21 M0 Mini  * 48 MHz ARM Cortex-M0+ * Arduino 1.8.16, Arduino CLI 0.19.2 * Sparkfun SAMD Boards 1.8.4  ``` {samd_results} ```  (SAMD compiler does not produce RAM usage numbers.)  ## STM32 Blue Pill  * STM32F103C8, 72 MHz ARM Cortex-M3 * Arduino 1.8.16, Arduino CLI 0.19.2 * STM32duino 2.0.0  ``` {stm32_results} ```  ## ESP8266  * NodeMCU 1.0, 80MHz ESP8266 * Arduino 1.8.16, Arduino CLI 0.19.2 * ESP8266 Boards 3.0.2  ``` {esp8266_results} ```  ## ESP32  * ESP32-01 Dev Board, 240 MHz Tensilica LX6 * Arduino 1.8.16, Arduino CLI 0.19.2 * ESP32 Boards 1.0.6  ``` {esp32_results} ```  RAM usage remains constant as more objects are created, which indicates that an initial pool of a certain minimum size is created regardless of the actual RAM usage by objects.  ## Teensy 3.2  * 96 MHz ARM Cortex-M4 * Arduino 1.8.16, Arduino CLI 0.19.2 * Teensyduino 1.55  ``` {teensy32_results} ```