-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add script for memory measures
- Loading branch information
1 parent
b6ee61f
commit 334794d
Showing
6 changed files
with
76 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/bin/bash | ||
# This script measures ROM and static RAM memory usage of Arduino example with different features enabled | ||
# Memory info should be updated at following places: | ||
# /README.md in Demo section | ||
# /README.md in Memory section | ||
# /examples/arduino/README.md in example description | ||
|
||
memory_file="target/MEMORY.md" | ||
|
||
echo "## Memory usage" >$memory_file | ||
|
||
echo "| Features | ROM, bytes | Static RAM, bytes |" >>$memory_file | ||
echo "|----------|:----------:|:-----------------:|" >>$memory_file | ||
|
||
array=("autocomplete" "history" "help") | ||
n=${#array[@]} | ||
for ((i = 0; i < (1 << n); i++)); do | ||
list=() | ||
list_md=() | ||
for ((j = 0; j < n; j++)); do | ||
if (((1 << j) & i)); then | ||
list+=("${array[j]}") | ||
list_md+=("\`${array[j]}\`") | ||
fi | ||
done | ||
features=$( | ||
IFS=, | ||
echo "${list[*]}" | ||
) | ||
features_md=$( | ||
IFS=' ' | ||
echo "${list_md[*]}" | ||
) | ||
echo "Measuring features: $features" | ||
|
||
cp Cargo.toml Cargo.toml.bak | ||
|
||
cargo remove embedded-cli | ||
cargo add embedded-cli --path "../../embedded-cli" \ | ||
--no-default-features \ | ||
--features "macros, $features" | ||
|
||
cargo build --release | ||
|
||
ram_usage=$(avr-nm -Crtd --size-sort \ | ||
target/avr-atmega328p/release/arduino-cli.elf | | ||
grep -i ' [dbvr] ' | | ||
awk -F " " '{Total=Total+$1} END{print Total}' -) | ||
|
||
rom_usage=$(cargo bloat --release --message-format json | jq -cs '.[0]["text-section-size"]') | ||
|
||
echo "| $features_md | $rom_usage | $ram_usage |" >>$memory_file | ||
echo "$features: ROM=$rom_usage RAM=$ram_usage" | ||
|
||
mv Cargo.toml.bak Cargo.toml | ||
done |