From 0f317441039bb3a426ac5a163541c41d4bc41266 Mon Sep 17 00:00:00 2001 From: monosans Date: Mon, 2 Feb 2026 16:39:48 +0300 Subject: [PATCH] fix(allocator-bench): change cargo run to cargo build for performance measurement --- .github/scripts/allocator_bench_alpine.sh | 9 +++++++-- .github/scripts/allocator_bench_unix.sh | 9 ++++++++- .github/scripts/allocator_bench_windows.ps1 | 14 +++++++++++++- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/.github/scripts/allocator_bench_alpine.sh b/.github/scripts/allocator_bench_alpine.sh index 2bea082..14fbbff 100644 --- a/.github/scripts/allocator_bench_alpine.sh +++ b/.github/scripts/allocator_bench_alpine.sh @@ -30,9 +30,14 @@ build_features() { for allocator in system jemalloc mimalloc_v2 mimalloc_v3; do features="$(build_features "$allocator")" if [ -n "$features" ]; then - output="$(/usr/bin/time -v cargo run --release --locked --features "$features" 2>&1 >/dev/null)" + cargo build --release --locked --features "$features" else - output="$(/usr/bin/time -v cargo run --release --locked 2>&1 >/dev/null)" + cargo build --release --locked + fi + if [ -n "$features" ]; then + output="$(/usr/bin/time -v /work/target/release/proxy-scraper-checker 2>&1 >/dev/null)" + else + output="$(/usr/bin/time -v /work/target/release/proxy-scraper-checker 2>&1 >/dev/null)" fi peak="$(echo "$output" | awk -F': ' '/Maximum resident set size/ {print $2; exit}')" if [ -z "$peak" ]; then diff --git a/.github/scripts/allocator_bench_unix.sh b/.github/scripts/allocator_bench_unix.sh index b91bc6c..dc54ea8 100644 --- a/.github/scripts/allocator_bench_unix.sh +++ b/.github/scripts/allocator_bench_unix.sh @@ -46,8 +46,15 @@ run_one() { feature_args=(--features "$features") fi + cargo build --release --locked "${feature_args[@]}" + + local exe="target/release/proxy-scraper-checker" + if [[ "$RUNNER_OS" == "Windows" ]]; then + exe="target/release/proxy-scraper-checker.exe" + fi + local output - output="$(${time_cmd[@]} cargo run --release --locked "${feature_args[@]}" 2>&1 >/dev/null)" + output="$(${time_cmd[@]} "$exe" 2>&1 >/dev/null)" local peak peak="$(echo "$output" | parse_peak)" diff --git a/.github/scripts/allocator_bench_windows.ps1 b/.github/scripts/allocator_bench_windows.ps1 index 1939058..36b3041 100644 --- a/.github/scripts/allocator_bench_windows.ps1 +++ b/.github/scripts/allocator_bench_windows.ps1 @@ -11,7 +11,7 @@ function Build-Features([string]$allocator, [string]$tokio) { } function Run-One([string]$allocator, [string]$features) { - $args = @("run", "--release", "--locked") + $args = @("build", "--release", "--locked") if ($features) { $args += "--features"; $args += $features } $peak = 0 @@ -24,6 +24,18 @@ function Run-One([string]$allocator, [string]$features) { if ($current -gt $peak) { $peak = $current } } catch { } } + + $exe = "target\\release\\proxy-scraper-checker.exe" + $peak = 0 + $proc = Start-Process -FilePath $exe -PassThru -NoNewWindow + while (-not $proc.HasExited) { + Start-Sleep -Milliseconds 200 + try { + $p = Get-Process -Id $proc.Id -ErrorAction Stop + $current = [math]::Max($p.WorkingSet64, $p.PeakWorkingSet64) + if ($current -gt $peak) { $peak = $current } + } catch { } + } $peakKb = [math]::Floor($peak / 1kb) Add-Content -Path results.tsv -Value "$allocator`t$peakKb" }