aboutsummaryrefslogtreecommitdiffstats
path: root/ccomp_profiling/prof_function.sh
diff options
context:
space:
mode:
authorLéo Gourdin <leo.gourdin@univ-grenoble-alpes.fr>2022-01-05 15:32:46 +0100
committerLéo Gourdin <leo.gourdin@univ-grenoble-alpes.fr>2022-01-05 15:32:46 +0100
commit1749be90299633474d2acad39ec8c70df6ccab32 (patch)
tree0e1e6a0ca8dccfabb9688eb3ea5b94193223b1b2 /ccomp_profiling/prof_function.sh
parent7b5ea95586f59c14f64b76e02fb3443c5c1ef6b8 (diff)
downloadcompcert-kvx-1749be90299633474d2acad39ec8c70df6ccab32.tar.gz
compcert-kvx-1749be90299633474d2acad39ec8c70df6ccab32.zip
update from BTL dev branch
Diffstat (limited to 'ccomp_profiling/prof_function.sh')
-rwxr-xr-xccomp_profiling/prof_function.sh47
1 files changed, 47 insertions, 0 deletions
diff --git a/ccomp_profiling/prof_function.sh b/ccomp_profiling/prof_function.sh
new file mode 100755
index 00000000..0582a6ec
--- /dev/null
+++ b/ccomp_profiling/prof_function.sh
@@ -0,0 +1,47 @@
+#!/bin/bash
+# @author gourdinl
+# Script to profile several CompCert functions
+# Args: $1=jq program; $2=json file; $3=list of functions
+
+if [ $# -ne 3 ]; then
+ echo "Usage: ./prof_function.sh <jq_program> <json_file> <fct1;fct2;...>"
+ echo $#
+ exit 1
+fi
+
+JQ=$1
+JSON=$2
+FCTS=$3
+
+convert_to_bc () {
+ printf "%.20f" $1
+}
+
+test_name=$($JQ '.label' $JSON)
+total_cycles=$(convert_to_bc $($JQ '.nodes | .[] | select(.kind=="root") | .time' $JSON))
+total_time=$(convert_to_bc $($JQ '.nodes | .[] | select(.kind=="root") | .sys_time' $JSON))
+
+IFS=';'
+read -ra arr_FCTS <<< "$FCTS"
+sum_fct_time=0
+sum_fct_cycles=0
+for fct in ${arr_FCTS[@]}; do
+ echo $fct
+ fct_cycles=$(convert_to_bc $($JQ '.nodes | .[] | select(.name | test("'$fct'")) | .time' $JSON))
+ fct_time=$(convert_to_bc $($JQ '.nodes | .[] | select(.name | test("'$fct'")) | .sys_time' $JSON))
+ sum_fct_time=$(bc -l <<< "$sum_fct_time + $fct_time")
+ sum_fct_cycles=$(bc -l <<< "$sum_fct_cycles + $fct_cycles")
+done
+
+echo "total_cycles,total_time"
+echo "$total_cycles,$total_time"
+echo "sum_fct_cycles,sum_fct_time"
+echo "$sum_fct_cycles,$sum_fct_time"
+if (( $(bc -l <<< "$sum_fct_cycles > 0") )) && (( $(bc -l <<< "$sum_fct_time > 0") )); then
+ ratio_cycles=$(bc -l <<< "($sum_fct_cycles / $total_cycles) * 100")
+ ratio_time=$(bc -l <<< "($sum_fct_time / $total_time) * 100")
+ echo "test_name,ratio_cycles,ratio_time"
+ echo "$test_name,$ratio_cycles,$ratio_time"
+else
+ echo "$test_name,0,0"
+fi