param(
    [Parameter(Mandatory = $true)]
    [string] $PbfFile,
    [int] $Threads = [Math]::Max(1, [Math]::Min(16, [Environment]::ProcessorCount - 1)),
    [string] $ReportFile
)

$ErrorActionPreference = "Stop"
$projectRoot = Split-Path -Parent $PSScriptRoot
$applicationDir = Join-Path $projectRoot "application"
if (-not $ReportFile) {
    $ReportFile = Join-Path $projectRoot "documentation\benchmarks\parallel-pbf-windows.json"
}

& (Join-Path $applicationDir "gradlew.bat") -p $applicationDir `
    --project-cache-dir (Join-Path $projectRoot ".gradle-project-cache") `
    '-Pmaptools.buildRoot=../build-windows' `
    ":core:benchmarkPbf" `
    "-PpbfFile=$PbfFile" `
    "-PbenchmarkReport=$ReportFile" `
    "-PbenchmarkThreads=$Threads"
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

Write-Host "Benchmarkbericht: $ReportFile"
