Skip to content

Commit

Permalink
perf: Enable concurrent in codspeed bench (#9862)
Browse files Browse the repository at this point in the history
**Description:**

This PR enables cargo feature `concurrent` for codspeed benchmark done by CI machine for crates that have a such feature.
  • Loading branch information
kdy1 authored Jan 10, 2025
1 parent 4eabb40 commit 6c2bb13
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ jobs:
tool: cargo-codspeed@2.7.2

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

- name: Run the benchmarks
uses: CodSpeedHQ/action@v2
Expand Down
36 changes: 36 additions & 0 deletions scripts/bench/build-all-crates.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

set -eu

echo "Building all crates for codspeed"

WS_CRATES=$(./scripts/cargo/list-crates.sh)

# Get crate names
CRATE_NAMES=$(echo "$WS_CRATES" | jq -r '.name')

for crate in $CRATE_NAMES; do
# If crate is swc_plugin_runner, skip it
if [[ $crate == "swc_plugin_runner" ]]; then
continue
fi

crate_info=$(echo "$WS_CRATES" | jq -r 'select(.name == "'$crate'")')
bench_targets=$(echo $crate_info | jq -r '.targets[] | select(.kind | contains(["bench"]))')


# If crate has no benchmark target, skip it
if [[ -z $bench_targets ]]; then
echo "Skipping $crate because it has no benchmark target"
continue
fi

# If crate has feature 'concurrent', build it with feature
if [[ $(./scripts/cargo/list-features.sh $crate) == *"concurrent"* ]]; then
echo "Building $crate with feature 'concurrent'"
cargo codspeed build -p $crate --features concurrent
else
echo "Building $crate"
cargo codspeed build -p $crate
fi
done
9 changes: 9 additions & 0 deletions scripts/cargo/list-features.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -eu



# Prints json for workspace crates

cargo metadata --format-version 1 | jq -r '.packages[] | select(.source == null and .name == "'$1'") | .features'

0 comments on commit 6c2bb13

Please # to comment.