[16614] | 1 | [cmdletbinding()]
|
---|
| 2 | param(
|
---|
| 3 | [int] $WaitToStep = 200,
|
---|
| 4 | [int] $PeelCnt = 3,
|
---|
| 5 | [int] $EvalCnt = 3,
|
---|
| 6 | [ValidateSet("method1","method2", "method3")][string] $InitMethod = "method1",
|
---|
| 7 | [ValidateSet("method1","method2", "method3")][string] $GrowMethod = "method1",
|
---|
| 8 | [int] $MaxJobs = 30,
|
---|
| 9 | [switch] $Clear
|
---|
| 10 | )
|
---|
| 11 |
|
---|
| 12 | $BenchmarksPath = Resolve-Path -Relative "go-code\go-pge\data\benchmark"
|
---|
| 13 |
|
---|
| 14 | $Clean = $false
|
---|
| 15 | if($Clear) {
|
---|
| 16 | $Clean = $true
|
---|
| 17 | }
|
---|
| 18 |
|
---|
| 19 | $BenchFiles = Get-ChildItem -Path $BenchmarksPath -File
|
---|
| 20 | $ActiveJobs = @{}
|
---|
| 21 | foreach($BenchName in $($BenchFiles | Select-Object -ExpandProperty BaseName -Unique)) {
|
---|
| 22 | $RunningCnt = ($ActiveJobs.Values | Where-Object { $_.State -eq "Running" }).Count
|
---|
| 23 | while ($RunningCnt -gt $MaxJobs) {
|
---|
| 24 | Start-Sleep -Seconds 1
|
---|
| 25 | $RunningCnt = ($ActiveJobs.Values | Where-Object { $_.State -eq "Running" }).Count
|
---|
| 26 | }
|
---|
| 27 | $ActiveJobs[$BenchName] = Start-Job -ScriptBlock {
|
---|
| 28 | param($PSPath, $WaitToStep, $BenchName, $PeelCnt, $EvalCnt, $InitMethod, $GrowMethod, $Clear)
|
---|
| 29 | Set-Location -Path $PSPath
|
---|
| 30 | ./TestResults -WaitToStep $WaitToStep -BenchName $BenchName -PeelCnt $PeelCnt -EvalCnt $EvalCnt -InitMethod $InitMethod -GrowMethod $GrowMethod *>&1
|
---|
| 31 | } -ArgumentList $(Resolve-Path $PSScriptRoot), $WaitToStep, $BenchName, $PeelCnt, $EvalCnt, $InitMethod, $GrowMethod, $Clean
|
---|
| 32 | Write-Host "Started job for $BenchName"
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | $ActiveJobs.Values | Wait-Job | Out-Null
|
---|
| 36 | foreach($BenchName in $ActiveJobs.Keys) {
|
---|
| 37 | $Job = $ActiveJobs[$BenchName]
|
---|
| 38 | $Res = $Job | Receive-Job
|
---|
| 39 | $Succeeded = ($Res | Select-String -Pattern "^[0-9]+\sOK").Count
|
---|
| 40 | $Failed = ($Res | Select-String -Pattern "^[0-9]+\sfailed!").Count
|
---|
| 41 | if($($Succeeded + $Failed) -ne $WaitToStep ) {
|
---|
| 42 | Write-Error "Something went wrong!? Please check manuelly"
|
---|
| 43 | }
|
---|
| 44 | if($Succeeded -eq $WaitToStep) {
|
---|
| 45 | Write-Host "$($BenchName): $Succeeded / $WaitToStep tests succeeded"
|
---|
| 46 | } else {
|
---|
| 47 | Write-Warning "$($BenchName): $Failed / $WaitToStep tests failed!"
|
---|
| 48 | }
|
---|
| 49 | }
|
---|
| 50 | Get-Job | Remove-Job -Force | Out-Null |
---|