Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bytecodealliance
GitHub Repository: bytecodealliance/wasmtime
Path: blob/main/benches/wasmtime-serve-rps.sh
1685 views
1
#!/usr/bin/env bash
2
3
# Usage:
4
#
5
# wasmtime-serve-rps.sh [WASMTIME-FLAGS] path/to/wasi-http-component.wasm
6
#
7
# For a basic WASI HTTP component, check out
8
# https://github.com/sunfishcode/hello-wasi-http
9
#
10
# You must have the `hey` tool installed on your `$PATH`. It is available in at
11
# least the `apt` and `brew` package managers, as well as a binary download via
12
# its github page: https://github.com/rakyll/hey
13
14
set -e
15
16
repo_dir="$(dirname $0)/.."
17
cargo_toml="$repo_dir/Cargo.toml"
18
target_dir="$CARGO_TARGET_DIR"
19
if [[ "$target_dir" == "" ]]; then
20
target_dir="$repo_dir/target"
21
fi
22
23
# Build Wasmtime.
24
cargo build --manifest-path "$cargo_toml" --release -p wasmtime-cli
25
26
# Spawn `wasmtime serve` in the background.
27
"$target_dir/release/wasmtime" serve "$@" &
28
pid=$!
29
30
# Give it a second to print its diagnostic information and get the server up and
31
# running.
32
sleep 1
33
34
echo 'Running `wasmtime serve` in background as pid '"$pid"
35
36
# Benchmark the server!
37
echo "Benchmarking for 10 seconds..."
38
hey -z 10s http://0.0.0.0:8080/
39
40
kill "$pid"
41
42