@@ -42,10 +42,14 @@ slexe() {
42
42
}
43
43
# run bats_pipe bash bin/slexfe -F $1 \| slangroom-exec
44
44
>&3 echo " 🔥 `basename ${1}.slang`"
45
+ local start_time_s=$(date +%s)
46
+ local start_time_ns=$(date +%N)
45
47
bash bin/slexfe -F $1 \
46
48
| slangroom-exec \
47
49
1>$TMP/out 2> >(tee $TMP/err | grep -v 'J64 ' >&2)
48
50
local res=$?
51
+ local end_time_s=$(date +%s)
52
+ local end_time_ns=$(date +%N)
49
53
export output=`cat $TMP/out`
50
54
[ "$res" != 0 ] && {
51
55
>&2 echo "TRACE:"
@@ -60,11 +64,52 @@ slexe() {
60
64
_err "Output is missing, no result from previous computation" | tee -a $TMP/err
61
65
exit 1
62
66
}
67
+ # Avoid leading zero issues by normalizing inputs
68
+ start_time_s=$((10#$start_time_s))
69
+ start_time_ns=$((10#$start_time_ns))
70
+ end_time_s=$((10#$end_time_s))
71
+ end_time_ns=$((10#$end_time_ns))
72
+ # Convert and calculate elapsed time in milliseconds
73
+ local start_time_ms=$((start_time_s * 1000 + start_time_ns / 1000000))
74
+ local end_time_ms=$((end_time_s * 1000 + end_time_ns / 1000000))
75
+ local execution_time_ms=$((end_time_ms - start_time_ms))
63
76
rm -f "${1}.out.json"
64
77
echo "$output" > "${1}.out.json"
65
78
>&3 echo " 💾 `basename ${1}.out.json`"
66
79
>&3 echo ""
67
80
set -e
81
+ if [ -L $1.data.json ]; then
82
+ idata=`readlink $1.data.json`
83
+ local size=$(stat --format="%s" "$idata") # Get file size in bytes
84
+ idata="`basename $idata`\n\n$size bytes"
85
+ else
86
+ idata="null\n\n0 bytes"
87
+ fi
88
+ if [ -L $1.keys.json ]; then
89
+ ikeys=`readlink $1.keys.json`
90
+ local size=$(stat --format="%s" "$ikeys") # Get file size in bytes
91
+ ikeys="`basename $ikeys`\n\n$size bytes"
92
+ else
93
+ ikeys="null\n\n0 bytes"
94
+ fi
95
+ # size_kilobytes=$(echo "scale=2; $size / 1024" | bc)
96
+ iout="`basename $1`\n\n$(stat --format="%s" "$1.out.json") bytes"
97
+ cat <<EOF | dot -Tsvg -o ${1}.svg
98
+ digraph G {
99
+ rankdir=LR;
100
+ node [shape=box, style=rounded, fontname="Arial", fontsize=12, color=black, fillcolor=lightgray, margin=0.2];
101
+ bgcolor=transparent;
102
+ edge [arrowsize=0.8];
103
+ Input1 [label="$idata"];
104
+ Input2 [label="$ikeys"];
105
+ Script [shape=ellipse, label="zencode_exec\n\ntime: $execution_time_ms ms"];
106
+ Output [label="$iout"];
107
+ Input1 -> Script;
108
+ Input2 -> Script;
109
+ Script -> Output;
110
+ edge [color=black, arrowsize=0.7];
111
+ }
112
+ EOF
68
113
}
69
114
70
115
save_output() {
@@ -78,7 +123,7 @@ save_output() {
78
123
>&3 echo " 💾 > `basename $1`"
79
124
}
80
125
81
- prepare () {
126
+ input () {
82
127
[ -r "$2" ] || {
83
128
_err "Input file not found: $2" | tee -a $TMP/err
84
129
exit 1
0 commit comments