-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbench.sh
executable file
·90 lines (74 loc) · 2.29 KB
/
bench.sh
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env bash
cpwd="$(pwd)"
required_bins=('cargo' 'go' 'python' 'dub' 'hyperfine')
rust_bins=('rust-reqwest' 'rust-ureq')
go_bins=('go-http-client')
dotnet_bins=('dotnet-http-client')
python_bins=('python-requests' 'python-urllib' 'python-httpx')
dlang_bins=('dlang-server' 'dlang-arsd' 'dlang-vibed' 'dlang-requests')
for required_bin in "${required_bins[@]}"; do
if ! command -v "${required_bin}" &>/dev/null; then
echo "$required_bin is not installed!"
exit 1
fi
done
for rust_bin in "${rust_bins[@]}"; do
echo "Building ${rust_bin}..."
cargo build --release --manifest-path "${cpwd}/${rust_bin}/Cargo.toml"
done
for go_bin in "${go_bins[@]}"; do
echo "Building ${go_bin}..."
cd "${cpwd}/${go_bin}" || exit
go build "${go_bin}.go"
done
for dotnet_bin in "${dotnet_bins[@]}"; do
echo "Building ${dotnet_bin}..."
cd "${cpwd}/${dotnet_bin}" || exit
dotnet build --configuration Release
done
for dlang_bin in "${dlang_bins[@]}"; do
echo "Building ${dlang_bin}..."
dub build -b=release --root="${cpwd}/${dlang_bin}"
done
cd "${cpwd}" || exit
server_bins=(
"${dlang_bins[0]}/${dlang_bins[0]}"
)
echo "Running the server..."
"${cpwd}/${server_bins[0]}" &
SERVER_PID=$!
trap 'kill -9 $SERVER_PID' SIGINT SIGTERM
args=(
"--warmup" "5"
"--runs" "50"
"-N"
"--command-name" "go-http-client"
"--command-name" "dotnet-http-client"
"--command-name" "python-requests"
"--command-name" "python-urllib"
"--command-name" "python-httpx"
"--command-name" "rust-reqwest"
"--command-name" "rust-ureq"
"--command-name" "dlang-arsd"
"--command-name" "dlang-vibed"
"--command-name" "dlang-requests"
)
sleep 2
for go_bin in "${go_bins[@]}"; do
commands=("${cpwd}/${go_bin}/${go_bin}")
done
for dotnet_bin in "${dotnet_bins[@]}"; do
commands+=("${cpwd}/${dotnet_bin}/bin/Release/net8.0/${dotnet_bin}")
done
for python_bin in "${python_bins[@]}"; do
commands+=("python ${cpwd}/${python_bin}/${python_bin}.py")
done
for rust_bin in "${rust_bins[@]}"; do
commands+=("${cpwd}/${rust_bin}/target/release/${rust_bin}")
done
for dlang_bin in "${dlang_bins[@]:1}"; do
commands+=("${cpwd}/${dlang_bin}/${dlang_bin}")
done
hyperfine "${args[@]}" "${commands[@]}" -i --export-json benchmarks.json --export-markdown benchmarks.md
sed -i "s|${cpwd}\/||g" benchmarks.*
kill -9 "$SERVER_PID"