@@ -30,17 +30,14 @@ slexe() {
30
30
set +e
31
31
[ -r bin/slexfe ] || {
32
32
_err "Error: bin/slexfe not found." | tee -a $TMP/err
33
- exit 1
34
- }
33
+ exit 1 }
35
34
command -v slangroom-exec > /dev/null || {
36
35
_err "Error: slangroom-exec not found." | tee -a $TMP/err
37
- exit 1
38
- }
36
+ exit 1 }
39
37
[ -r "${1}.slang" ] || {
40
38
_err "Error: script not found: $1" | tee -a $TMP/err
41
- exit 1
42
- }
43
- # run bats_pipe bash bin/slexfe -F $1 \| slangroom-exec
39
+ exit 1 }
40
+ # EXECUTION (timed)
44
41
>&3 echo " 🔥 `basename ${1}.slang`"
45
42
local start_time_s=$(date +%s)
46
43
local start_time_ns=$(date +%N)
@@ -51,20 +48,20 @@ slexe() {
51
48
local end_time_s=$(date +%s)
52
49
local end_time_ns=$(date +%N)
53
50
export output=`cat $TMP/out`
51
+ # analyze and print logs in case of error
54
52
[ "$res" != 0 ] && {
55
53
>&2 echo "TRACE:"
56
54
awk '/J64 TRACE/ {print $3}' $TMP/err | \
57
55
cut -d\" -f1 | base64 -d | jq .
58
56
>&2 echo "HEAP:"
59
57
awk '/J64 HEAP/ {print $3}' $TMP/err | \
60
58
cut -d\" -f1 | base64 -d | jq .
61
- exit 1
62
- }
59
+ exit 1 }
63
60
[ "$output" == "" ] && {
64
61
_err "Output is missing, no result from previous computation" | tee -a $TMP/err
65
- exit 1
66
- }
67
- # Avoid leading zero issues by normalizing inputs
62
+ exit 1 }
63
+ # Calculate execution timing:
64
+ # avoid leading zero issues in shell by normalizing inputs
68
65
start_time_s=$((10#$start_time_s))
69
66
start_time_ns=$((10#$start_time_ns))
70
67
end_time_s=$((10#$end_time_s))
@@ -73,26 +70,27 @@ slexe() {
73
70
local start_time_ms=$((start_time_s * 1000 + start_time_ns / 1000000))
74
71
local end_time_ms=$((end_time_s * 1000 + end_time_ns / 1000000))
75
72
local execution_time_ms=$((end_time_ms - start_time_ms))
73
+ # Write the output
76
74
rm -f "${1}.out.json"
77
75
echo "$output" > "${1}.out.json"
78
76
>&3 echo " 💾 `basename ${1}.out.json`"
79
77
>&3 echo ""
80
- set -e
78
+ set -e # relax
79
+ # Generate execution graph
81
80
if [ -L $1.data.json ]; then
82
81
idata=`readlink $1.data.json`
83
82
local size=$(stat --format="%s" "$idata") # Get file size in bytes
84
- idata="`basename $idata`\n\n$size bytes"
83
+ idata="`basename $idata|cut -d. -f1 `\n\n$size bytes"
85
84
else
86
85
idata="null\n\n0 bytes"
87
86
fi
88
87
if [ -L $1.keys.json ]; then
89
88
ikeys=`readlink $1.keys.json`
90
89
local size=$(stat --format="%s" "$ikeys") # Get file size in bytes
91
- ikeys="`basename $ikeys`\n\n$size bytes"
90
+ ikeys="`basename $ikeys|cut -d. -f1 `\n\n$size bytes"
92
91
else
93
92
ikeys="null\n\n0 bytes"
94
93
fi
95
- # size_kilobytes=$(echo "scale=2; $size / 1024" | bc)
96
94
iout="`basename $1`\n\n$(stat --format="%s" "$1.out.json") bytes"
97
95
cat <<EOF | dot -Tsvg -o ${1}.svg
98
96
digraph G {
@@ -110,6 +108,7 @@ digraph G {
110
108
edge [color=black, arrowsize=0.7];
111
109
}
112
110
EOF
111
+ # add entry to execution log
113
112
}
114
113
115
114
save_output() {
0 commit comments