Skip to content

Commit 6c2bb13

Browse files
authored
perf: Enable concurrent in codspeed bench (#9862)
**Description:** This PR enables cargo feature `concurrent` for codspeed benchmark done by CI machine for crates that have a such feature.
1 parent 4eabb40 commit 6c2bb13

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

.github/workflows/bench.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ jobs:
9999
tool: cargo-codspeed@2.7.2
100100

101101
- name: Build the benchmark target(s)
102-
run: cargo codspeed build --workspace --exclude swc_plugin_runner
102+
run: ./scripts/bench/build-all-crates.sh
103103

104104
- name: Run the benchmarks
105105
uses: CodSpeedHQ/action@v2

scripts/bench/build-all-crates.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env bash
2+
3+
set -eu
4+
5+
echo "Building all crates for codspeed"
6+
7+
WS_CRATES=$(./scripts/cargo/list-crates.sh)
8+
9+
# Get crate names
10+
CRATE_NAMES=$(echo "$WS_CRATES" | jq -r '.name')
11+
12+
for crate in $CRATE_NAMES; do
13+
# If crate is swc_plugin_runner, skip it
14+
if [[ $crate == "swc_plugin_runner" ]]; then
15+
continue
16+
fi
17+
18+
crate_info=$(echo "$WS_CRATES" | jq -r 'select(.name == "'$crate'")')
19+
bench_targets=$(echo $crate_info | jq -r '.targets[] | select(.kind | contains(["bench"]))')
20+
21+
22+
# If crate has no benchmark target, skip it
23+
if [[ -z $bench_targets ]]; then
24+
echo "Skipping $crate because it has no benchmark target"
25+
continue
26+
fi
27+
28+
# If crate has feature 'concurrent', build it with feature
29+
if [[ $(./scripts/cargo/list-features.sh $crate) == *"concurrent"* ]]; then
30+
echo "Building $crate with feature 'concurrent'"
31+
cargo codspeed build -p $crate --features concurrent
32+
else
33+
echo "Building $crate"
34+
cargo codspeed build -p $crate
35+
fi
36+
done

scripts/cargo/list-features.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
set -eu
4+
5+
6+
7+
# Prints json for workspace crates
8+
9+
cargo metadata --format-version 1 | jq -r '.packages[] | select(.source == null and .name == "'$1'") | .features'

0 commit comments

Comments
 (0)