mirror of
https://github.com/SukkaW/Surge.git
synced 2026-09-13 02:54:38 +08:00
119 lines
3.6 KiB
YAML
119 lines
3.6 KiB
YAML
name: Benchmark Download Client
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
mode:
|
|
description: Download client implementation to benchmark
|
|
required: true
|
|
default: both
|
|
type: choice
|
|
options:
|
|
- both
|
|
- fetch
|
|
- request
|
|
concurrency:
|
|
description: Maximum number of concurrent downloads
|
|
required: true
|
|
default: "18"
|
|
type: string
|
|
rounds:
|
|
description: Measured rounds; mode order alternates between rounds
|
|
required: true
|
|
default: "2"
|
|
type: string
|
|
warmup:
|
|
description: Warm shared DNS/CDN state with both clients before measuring
|
|
required: true
|
|
default: true
|
|
type: boolean
|
|
encoding:
|
|
description: Accepted response compression; all enables Brotli, gzip, deflate, and zstd
|
|
required: true
|
|
default: all
|
|
type: choice
|
|
options:
|
|
- all
|
|
- gzip
|
|
- identity
|
|
urls:
|
|
description: Optional URLs, one per line; empty uses the configured reject and phishing sources
|
|
required: false
|
|
type: string
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
benchmark:
|
|
name: ${{ inputs.mode }} at concurrency ${{ inputs.concurrency }} (${{ inputs.rounds }} rounds)
|
|
runs-on: ubuntu-24.04-arm
|
|
timeout-minutes: 20
|
|
|
|
steps:
|
|
- uses: smorimoto/tune-github-hosted-runner-network@v1
|
|
# Keep the runner network setup comparable with the production build.
|
|
- uses: actions/checkout@v7
|
|
with:
|
|
persist-credentials: false
|
|
- name: Set up pnpm
|
|
id: setup_pnpm
|
|
uses: pnpm/action-setup@v6
|
|
background: true
|
|
with:
|
|
run_install: false
|
|
cache: true
|
|
- name: Set up Node.js
|
|
id: setup_node
|
|
uses: actions/setup-node@v6
|
|
background: true
|
|
with:
|
|
node-version-file: ".node-version"
|
|
package-manager-cache: false
|
|
- wait: [setup_pnpm, setup_node]
|
|
- run: pnpm config set --location=global minimumReleaseAge 0
|
|
- run: pnpm install
|
|
- name: Run download benchmark
|
|
shell: bash
|
|
env:
|
|
BENCHMARK_MODE: ${{ inputs.mode }}
|
|
BENCHMARK_CONCURRENCY: ${{ inputs.concurrency }}
|
|
BENCHMARK_ROUNDS: ${{ inputs.rounds }}
|
|
BENCHMARK_WARMUP: ${{ inputs.warmup }}
|
|
BENCHMARK_ENCODING: ${{ inputs.encoding }}
|
|
BENCHMARK_URLS: ${{ inputs.urls }}
|
|
run: |
|
|
benchmark_args=(
|
|
"--mode=${BENCHMARK_MODE}"
|
|
"--concurrency=${BENCHMARK_CONCURRENCY}"
|
|
"--rounds=${BENCHMARK_ROUNDS}"
|
|
"--warmup=${BENCHMARK_WARMUP}"
|
|
"--encoding=${BENCHMARK_ENCODING}"
|
|
)
|
|
|
|
if [[ -n "${BENCHMARK_URLS}" ]]; then
|
|
while IFS= read -r url; do
|
|
url="${url%$'\r'}"
|
|
if [[ -n "${url}" ]]; then
|
|
benchmark_args+=("${url}")
|
|
fi
|
|
done <<< "${BENCHMARK_URLS}"
|
|
fi
|
|
|
|
pnpm run bench-download -- "${benchmark_args[@]}" | tee benchmark-output.txt
|
|
|
|
{
|
|
echo "## Download client benchmark"
|
|
echo
|
|
echo "- Runner: \`ubuntu-24.04-arm\`"
|
|
echo "- Mode: \`${BENCHMARK_MODE}\`"
|
|
echo "- Concurrency: \`${BENCHMARK_CONCURRENCY}\`"
|
|
echo "- Measured rounds: \`${BENCHMARK_ROUNDS}\`"
|
|
echo "- Warm-up: \`${BENCHMARK_WARMUP}\`"
|
|
echo "- Accept-Encoding: \`${BENCHMARK_ENCODING}\`"
|
|
echo
|
|
echo '```text'
|
|
cat benchmark-output.txt
|
|
echo '```'
|
|
} >> "${GITHUB_STEP_SUMMARY}"
|