refactor: streamline allocator benchmark scripts for improved readability and performance
This commit is contained in:
@@ -13,24 +13,18 @@ function Build-Features([string]$allocator, [string]$tokio) {
|
||||
function Run-One([string]$allocator, [string]$features) {
|
||||
$args = @("build", "--release", "--locked")
|
||||
if ($features) { $args += "--features"; $args += $features }
|
||||
|
||||
$proc = Start-Process -FilePath "cargo" -ArgumentList $args -PassThru -NoNewWindow -Wait
|
||||
|
||||
$peak = 0
|
||||
$proc = Start-Process -FilePath "cargo" -ArgumentList $args -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 { }
|
||||
}
|
||||
|
||||
$exe = "target\\release\\proxy-scraper-checker.exe"
|
||||
$exe = "target\release\proxy-scraper-checker.exe"
|
||||
|
||||
$proc = Start-Process -FilePath $exe -PassThru -NoNewWindow
|
||||
|
||||
$peak = 0
|
||||
$faults = 0
|
||||
$proc = Start-Process -FilePath $exe -PassThru -NoNewWindow
|
||||
|
||||
while (-not $proc.HasExited) {
|
||||
Start-Sleep -Milliseconds 200
|
||||
Start-Sleep -Milliseconds 100
|
||||
try {
|
||||
$p = Get-Process -Id $proc.Id -ErrorAction Stop
|
||||
$current = [math]::Max($p.WorkingSet64, $p.PeakWorkingSet64)
|
||||
@@ -38,6 +32,7 @@ function Run-One([string]$allocator, [string]$features) {
|
||||
if ($p.PageFaults -gt $faults) { $faults = $p.PageFaults }
|
||||
} catch { }
|
||||
}
|
||||
|
||||
$peakKb = [math]::Floor($peak / 1kb)
|
||||
Add-Content -Path results.tsv -Value "$allocator`t$peakKb`t$faults"
|
||||
}
|
||||
@@ -48,25 +43,15 @@ foreach ($allocator in $allocators) {
|
||||
Run-One $allocator $features
|
||||
}
|
||||
|
||||
$rows = Get-Content results.tsv | ForEach-Object {
|
||||
$parts = $_ -split "`t"
|
||||
[pscustomobject]@{
|
||||
Allocator = $parts[0]
|
||||
PeakKB = [int]$parts[1]
|
||||
PageFaults = [int]$parts[2]
|
||||
}
|
||||
}
|
||||
$sorted = $rows | Sort-Object PeakKB, PageFaults
|
||||
$best = $sorted | Select-Object -First 1
|
||||
|
||||
$summary = @()
|
||||
$summary += "### $($env:PLATFORM_LABEL) (tokio-multi-thread=$tokioOn)"
|
||||
$summary += ""
|
||||
$summary += "| Allocator | Peak KB | Page Faults |"
|
||||
$summary += "| --- | ---: | ---: |"
|
||||
foreach ($row in $sorted) {
|
||||
$summary += "| $($row.Allocator) | $($row.PeakKB) | $($row.PageFaults) |"
|
||||
|
||||
Get-Content results.tsv | ForEach-Object {
|
||||
$parts = $_ -split "`t"
|
||||
$summary += "| $($parts[0]) | $($parts[1]) | $($parts[2]) |"
|
||||
}
|
||||
$summary += ""
|
||||
$summary += "**Best:** $($best.Allocator) ($($best.PeakKB) KB, $($best.PageFaults) page faults)"
|
||||
$summary -join "`n" | Add-Content $env:GITHUB_STEP_SUMMARY
|
||||
|
||||
Reference in New Issue
Block a user