|
| 1 | +<# |
| 2 | +.SYNOPSIS |
| 3 | + One-click benchmark: generate Excel → convert to PDF (MiniPdf + LibreOffice) → compare → report. |
| 4 | +
|
| 5 | +.DESCRIPTION |
| 6 | + This script orchestrates the full MiniPdf self-evolution pipeline on Windows. |
| 7 | + It installs Python dependencies, runs all steps, and opens the final report. |
| 8 | +
|
| 9 | +.EXAMPLE |
| 10 | + .\Run-Benchmark.ps1 |
| 11 | + .\Run-Benchmark.ps1 -CompareOnly |
| 12 | + .\Run-Benchmark.ps1 -SkipReference |
| 13 | +#> |
| 14 | + |
| 15 | +param( |
| 16 | + [switch]$CompareOnly, |
| 17 | + [switch]$SkipGenerate, |
| 18 | + [switch]$SkipMiniPdf, |
| 19 | + [switch]$SkipReference, |
| 20 | + [switch]$SkipInstall |
| 21 | +) |
| 22 | + |
| 23 | +$ErrorActionPreference = "Continue" |
| 24 | +$ScriptRoot = $PSScriptRoot |
| 25 | +$BenchmarkDir = Join-Path $ScriptRoot "tests" "MiniPdf.Benchmark" |
| 26 | + |
| 27 | +Write-Host "`n============================================================" -ForegroundColor Cyan |
| 28 | +Write-Host " MiniPdf Self-Evolution Benchmark Pipeline" -ForegroundColor Cyan |
| 29 | +Write-Host "============================================================`n" -ForegroundColor Cyan |
| 30 | + |
| 31 | +# Step 0: Install Python dependencies |
| 32 | +if (-not $SkipInstall) { |
| 33 | + Write-Host "[Step 0] Installing Python dependencies..." -ForegroundColor Yellow |
| 34 | + pip install openpyxl pymupdf --quiet 2>$null |
| 35 | + if ($LASTEXITCODE -ne 0) { |
| 36 | + Write-Host " WARNING: pip install had issues. Continuing anyway..." -ForegroundColor DarkYellow |
| 37 | + } else { |
| 38 | + Write-Host " OK" -ForegroundColor Green |
| 39 | + } |
| 40 | +} |
| 41 | + |
| 42 | +# Build args for Python pipeline |
| 43 | +$pyArgs = @() |
| 44 | +if ($CompareOnly) { $pyArgs += "--compare-only" } |
| 45 | +if ($SkipGenerate) { $pyArgs += "--skip-generate" } |
| 46 | +if ($SkipMiniPdf) { $pyArgs += "--skip-minipdf" } |
| 47 | +if ($SkipReference) { $pyArgs += "--skip-reference" } |
| 48 | + |
| 49 | +# Run the benchmark pipeline |
| 50 | +Write-Host "`n[Running] python run_benchmark.py $($pyArgs -join ' ')`n" -ForegroundColor Yellow |
| 51 | +Push-Location $BenchmarkDir |
| 52 | +try { |
| 53 | + python run_benchmark.py @pyArgs |
| 54 | +} finally { |
| 55 | + Pop-Location |
| 56 | +} |
| 57 | + |
| 58 | +# Open the report if it exists |
| 59 | +$reportPath = Join-Path $BenchmarkDir "reports" "comparison_report.md" |
| 60 | +if (Test-Path $reportPath) { |
| 61 | + Write-Host "`n[Done] Report: $reportPath" -ForegroundColor Green |
| 62 | + Write-Host "Opening report..." -ForegroundColor Cyan |
| 63 | + # Open in VS Code if available, otherwise notepad |
| 64 | + $code = Get-Command code -ErrorAction SilentlyContinue |
| 65 | + if ($code) { |
| 66 | + code $reportPath |
| 67 | + } else { |
| 68 | + Start-Process notepad.exe -ArgumentList $reportPath |
| 69 | + } |
| 70 | +} else { |
| 71 | + Write-Host "`nNo report generated. Check the output above for errors." -ForegroundColor Red |
| 72 | +} |
0 commit comments