blob: 74d183bf2ce17389c1535b627bd5236e22bcd312 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#!/usr/bin/env bash
set -euo pipefail
REPO_ROOT="$(git -C "$(dirname "${BASH_SOURCE[0]}")" rev-parse --show-toplevel)"
BIN="$REPO_ROOT/target/release/shirabe"
PACKAGE="laravel/laravel"
for arg in "$@"; do
case "$arg" in
--package=*) PACKAGE="${arg#*=}" ;;
*) echo "unknown option: $arg" >&2; exit 2 ;;
esac
done
if ! command -v hyperfine >/dev/null 2>&1; then
echo "hyperfine not found; install it first (e.g. 'cargo install hyperfine')" >&2
exit 1
fi
cargo build --manifest-path "$REPO_ROOT/Cargo.toml" --release --bin shirabe
OUTDIR="${TMPDIR:-/tmp}/shirabe-bench-create-project-$$"
mkdir -p "$OUTDIR"
cd "$OUTDIR"
TARGET_DIR="project-under-test"
PACKAGE_SLUG="${PACKAGE//\//-}"
hyperfine \
--warmup 1 \
--prepare "rm -rf '$TARGET_DIR-shirabe' '$TARGET_DIR-composer'" \
--export-json "$OUTDIR/results-$PACKAGE_SLUG.json" \
--export-markdown "$OUTDIR/results-$PACKAGE_SLUG.md" \
--show-output \
--command-name Shirabe "RUST_BACKTRACE=1 '$BIN' create-project --profile --no-plugins --no-scripts --no-audit '$PACKAGE' '$TARGET_DIR-shirabe'" \
--command-name Composer "composer create-project --profile --no-plugins --no-scripts --no-audit '$PACKAGE' '$TARGET_DIR-composer'"
echo ">> results: $OUTDIR/results-$PACKAGE_SLUG.json" >&2
echo ">> $OUTDIR/results-$PACKAGE_SLUG.md" >&2
|