-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathmemory.sh
More file actions
executable file
·56 lines (45 loc) · 1.53 KB
/
memory.sh
File metadata and controls
executable file
·56 lines (45 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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