Skip to content

Commit 32d6090

Browse files
ttuegelrv-jenkins
andauthored
Add a script to time execution steps (#2527)
* kore-exec-step.sh: Run programs step-wise * kore-exec-step.sh: Parse command line arguments * kore-exec-step.sh: Remove print debugging * kore-exec-step.sh: Add --depth option * kore-exec-step.sh: Exit loop on SIGINT * kore-exec-step.sh: Ignore --output flag * kore-exec-step.sh: Name CSV file after original pattern * kore-exec-step.sh: Add usage documentation Co-authored-by: rv-jenkins <[email protected]>
1 parent 8580044 commit 32d6090

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

kore-exec-step.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env bash
2+
3+
# USAGE: Pass the output of `krun --dry-run` to this script on the command line.
4+
5+
set_results() {
6+
last_result="result-$(printf "%04d" $last).kore"
7+
next_result="result-$(printf "%04d" $next).kore"
8+
}
9+
(( last = 0 ))
10+
(( next = 1 ))
11+
set_results
12+
13+
kore_exec_args=()
14+
while [[ $# -gt 0 ]]
15+
do
16+
case "$1" in
17+
--pattern)
18+
pattern="$2"
19+
shift
20+
;;
21+
--output)
22+
shift
23+
;;
24+
--depth)
25+
depth="$2"
26+
shift
27+
;;
28+
*)
29+
kore_exec_args+=("$1")
30+
esac
31+
shift
32+
done
33+
34+
if [[ -z "$pattern" ]]
35+
then
36+
echo >&2 "Error: Missing --pattern FILENAME argument"
37+
exit 1
38+
fi
39+
last_result="$pattern"
40+
csv_file="$pattern.csv"
41+
42+
trap 'exit 1' SIGINT
43+
44+
while [[ -z "$depth" ]] || [[ "$last" -lt "$depth" ]]
45+
do
46+
command time -f '%S,%U,%M' -o "${csv_file:?}" -a -q \
47+
kore-exec "${kore_exec_args[@]}" \
48+
--pattern "${last_result:?}" --output "${next_result:?}" --depth 1
49+
if diff "$last_result" "$next_result" >/dev/null; then break; fi
50+
(( last = next ))
51+
(( next += 1 ))
52+
set_results
53+
done

0 commit comments

Comments
 (0)