Skip to content

Commit 5f47fec

Browse files
committed
ci: Extract suite splitting to script
1 parent 1ff5a9f commit 5f47fec

File tree

2 files changed

+56
-10
lines changed

2 files changed

+56
-10
lines changed

.github/workflows/benchmarks.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ jobs:
5050
strategy:
5151
matrix:
5252
partition: ["00", "01", "02", "03", "04", "05", "06", "07"]
53+
env:
54+
- SPLIT_PREFIX: "benchmarks/split-"
55+
- PARTITION_SUITE: "${{ env.SPLIT_PREFIX }}${{ matrix.partition }}.suite"
5356
steps:
5457
- uses: actions/checkout@v4
5558
- name: Downloads All Artifacts (root)
@@ -61,17 +64,10 @@ jobs:
6164
- run: chmod +x artifacts/*/*.so
6265
- name: Partition Benchmark Suite
6366
run: |
64-
ceil_div() { echo "($1 + $2 - 1) / $2" | bc; }
65-
tmpdir=$(mktemp -d)
66-
grep -v '^\#' benchmarks/all.suite > $tmpdir/all.suite
67-
line_count=$(wc -l "$tmpdir/all.suite" | awk '{print $1}')
68-
lines_per_chunk=$(ceil_div "$line_count" "$PARTITIONS")
69-
split -d -l "$lines_per_chunk" "$tmpdir/all.suite" "${tmpdir}/all.split."
70-
cp "$tmpdir/all.split.${{ matrix.partition }}" benchmarks/split.${{ matrix.partition }}.suite
71-
rm -rf "$tmpdir"
67+
benchmarks/split-suite.sh benchmarks/all.suite "${SPLIT_PREFIX}"
7268
7369
- name: Output Running Benchmarks
74-
run: cat "benchmarks/split.${{ matrix.partition }}.suite"
70+
run: cat "${PARTITION_SUITE}"
7571

7672
- name: Benchmark Partition ${{ matrix.partition }}
7773
run: |
@@ -80,7 +76,7 @@ jobs:
8076
--engine=artifacts/wasmtime-v25.0.0/libengine.so \
8177
--processes=4 \
8278
--iterations-per-process=1 \
83-
-- "benchmarks/split.${{ matrix.partition }}.suite"
79+
-- "${PARTITION_SUITE}"
8480
8581
check:
8682
runs-on: ubuntu-latest

benchmarks/split-suite.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env sh
2+
#
3+
# This script splits a test suite into N roughly
4+
# equally sized test suites using the provided
5+
# output prefix.
6+
#
7+
# Usage:
8+
# ./ci-split.sh <input.suite> <N> <output-prefix>
9+
#
10+
# The naming of the split files will being in the form generated
11+
# by `split` which is `<prefix><num>.suite` where num is in %02d
12+
# format; for example, a prefix of "benchmarks/split-" will yield
13+
# files with names like benchmarks/split-07.suite.
14+
15+
set -e
16+
17+
if [ "$#" -ne 3 ]; then
18+
echo "Usage: $0 <suite> <number splits> <output prefix>"
19+
exit 1
20+
fi
21+
22+
SUITE="$1"
23+
NUMBER_SPLITS="$2"
24+
OUTPUT_PREFIX="$3"
25+
26+
ceil_div() {
27+
echo "($1 + $2 - 1) / $2" | bc
28+
}
29+
30+
count_lines() {
31+
wc -l "$1" | awk '{print $1}'
32+
}
33+
34+
tmpdir="$(mktemp -d)"
35+
tmp_suite="${tmpdir}/input.suite"
36+
grep -v '^\#' "${SUITE}" > "${tmp_suite}"
37+
line_count=$(count_lines "${tmp_suite}")
38+
lines_per_split=$(ceil_div "$line_count" "$NUMBER_SPLITS")
39+
split -d -l "$lines_per_split" "${tmp_suite}" "${OUTPUT_PREFIX}"
40+
rm -rf "$tmpdir"
41+
42+
echo "Generated Splits:"
43+
for f in "${OUTPUT_PREFIX}"*; do
44+
# suite files must end with ".suite" to work correctly
45+
# with sigtglass, so do the rename as split isn't
46+
# able to do it directly.
47+
suited="${f}.suite"
48+
mv "$f" "${suited}"
49+
echo "- ${suited}"
50+
done

0 commit comments

Comments
 (0)