Skip to content

Commit 99bc9e6

Browse files
committed
chore: Add shell script to benchmark different versions
1 parent 3c55e82 commit 99bc9e6

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

benchmark.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+
repo=$(realpath $(dirname "$0"))
4+
tags=(
5+
0.25.5
6+
0.26.0
7+
0.27.5
8+
0.28.2
9+
0.29.1
10+
0.30.1
11+
0.31.0
12+
HEAD
13+
)
14+
echo "Testing tags: ${tags[@]}"
15+
16+
mkdir /tmp/griffe-benchmark &>/dev/null
17+
cd /tmp/griffe-benchmark
18+
19+
echo "Preparing environments"
20+
for tag in ${tags[@]}; do
21+
(
22+
if ! [ -d "venv${tag}" ]; then
23+
python3.11 -m venv venv${tag}
24+
if [ "${tag}" = "HEAD" ]; then
25+
venv${tag}/bin/python -m pip install -e "${repo}" &>/dev/null
26+
else
27+
venv${tag}/bin/python -m pip install griffe==${tag} &>/dev/null
28+
fi
29+
fi
30+
) &
31+
done
32+
wait
33+
34+
cat <<EOF >benchmark.py
35+
import sys
36+
from griffe.loader import GriffeLoader
37+
stblib_packages = sorted([m for m in sys.stdlib_module_names if not m.startswith("_")])
38+
loader = GriffeLoader(allow_inspection=False)
39+
for package in stblib_packages:
40+
try:
41+
loader.load_module(package)
42+
except Exception:
43+
pass
44+
loader.resolve_aliases(implicit=False, external=False)
45+
EOF
46+
47+
commands=$(
48+
for tag in ${tags[@]}; do
49+
echo "'venv${tag}/bin/python benchmark.py'"
50+
done
51+
)
52+
53+
eval hyperfine --runs 3 ${commands} --export-json benchmark.json

0 commit comments

Comments
 (0)