Path: blob/main/benches/wasmtime-serve-rps.sh
1685 views
#!/usr/bin/env bash12# Usage:3#4# wasmtime-serve-rps.sh [WASMTIME-FLAGS] path/to/wasi-http-component.wasm5#6# For a basic WASI HTTP component, check out7# https://github.com/sunfishcode/hello-wasi-http8#9# You must have the `hey` tool installed on your `$PATH`. It is available in at10# least the `apt` and `brew` package managers, as well as a binary download via11# its github page: https://github.com/rakyll/hey1213set -e1415repo_dir="$(dirname $0)/.."16cargo_toml="$repo_dir/Cargo.toml"17target_dir="$CARGO_TARGET_DIR"18if [[ "$target_dir" == "" ]]; then19target_dir="$repo_dir/target"20fi2122# Build Wasmtime.23cargo build --manifest-path "$cargo_toml" --release -p wasmtime-cli2425# Spawn `wasmtime serve` in the background.26"$target_dir/release/wasmtime" serve "$@" &27pid=$!2829# Give it a second to print its diagnostic information and get the server up and30# running.31sleep 13233echo 'Running `wasmtime serve` in background as pid '"$pid"3435# Benchmark the server!36echo "Benchmarking for 10 seconds..."37hey -z 10s http://0.0.0.0:8080/3839kill "$pid"404142