forked from noir-lang/noir
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmemory_report.sh
More file actions
executable file
·65 lines (49 loc) · 1.97 KB
/
memory_report.sh
File metadata and controls
executable file
·65 lines (49 loc) · 1.97 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
57
58
59
60
61
62
63
64
#!/usr/bin/env bash
set -e
sudo apt-get install heaptrack
NARGO="nargo"
PARSE_MEMORY=$(realpath "$(dirname "$0")/parse_memory.sh")
# Tests to be profiled for memory report
tests_to_profile=("workspace" "regression_4709" "ram_blowup_regression" "global_var_regression_entry_points")
current_dir=$(pwd)
base_path="$current_dir/execution_success"
# If there is an argument that means we want to generate a report for only the current directory
if [ "$1" == "1" ]; then
base_path="$current_dir"
tests_to_profile=(".")
fi
FIRST="1"
FLAGS=${FLAGS:- ""}
echo "[" > memory_report.json
for test_name in ${tests_to_profile[@]}; do
cd $base_path/$test_name
if [ $FIRST = "1" ]
then
FIRST="0"
else
echo " ," >> $current_dir"/memory_report.json"
fi
if [ "$1" == "1" ]; then
test_name=$(basename $current_dir)
fi
COMMAND="compile --force --silence-warnings $FLAGS"
if [ "$2" == "1" ]; then
COMMAND="execute --silence-warnings"
fi
heaptrack --output $current_dir/$test_name"_heap" $NARGO $COMMAND
if test -f $current_dir/$test_name"_heap.gz";
then
heaptrack --analyze $current_dir/$test_name"_heap.gz" > $current_dir/$test_name"_heap_analysis.txt"
rm $current_dir/$test_name"_heap.gz"
else
heaptrack --analyze $current_dir/$test_name"_heap.zst" > $current_dir/$test_name"_heap_analysis.txt"
rm $current_dir/$test_name"_heap.zst"
fi
consumption="$(grep 'peak heap memory consumption' $current_dir/$test_name'_heap_analysis.txt')"
len=${#consumption}-30
peak=${consumption:30:len}
rm $current_dir/$test_name"_heap_analysis.txt"
peak_memory=$($PARSE_MEMORY $peak)
jq -rc "{name: \"$test_name\", value: \"$peak_memory\" | tonumber, unit: \"MB\"}" --null-input >> $current_dir/memory_report.json
done
echo "]" >> $current_dir"/memory_report.json"