Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2929_PrioritizedGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.PGE/3.3/MultiTest.ps1 @ 18242

Last change on this file since 18242 was 16620, checked in by hmaislin, 6 years ago

#2929: Reorganized folder structure for make script, removed explicit marshalling, erased go-side logging

File size: 2.6 KB
RevLine 
[16614]1[cmdletbinding()]
2param(
[16618]3    [int] $WaitToStep = 200,
[16614]4    [int] $PeelCnt = 3,
5    [int] $EvalCnt = 3,
6    [ValidateSet("method1","method2", "method3")][string] $InitMethod = "method1",
7    [ValidateSet("method1","method2", "method3")][string] $GrowMethod = "method1",
[16618]8    [int] $MaxJobs = 3,
[16617]9    [switch] $NoClear,
10    [switch] $UseExisting
[16614]11)
12
[16620]13$BenchmarksPath = Resolve-Path -Relative "src\go-pge\data\benchmark"
[16614]14
[16618]15$env:GOGC="off"
16$env:GODEBUG="cgocheck=0"
17$env:CGO_ENABLED=1
18
[16614]19$BenchFiles = Get-ChildItem -Path $BenchmarksPath -File
20$ActiveJobs = @{}
21foreach($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 {
[16617]28        param($PSPath, $WaitToStep, $BenchName, $PeelCnt, $EvalCnt, $InitMethod, $GrowMethod, $NoClear, $UseExisting)
[16614]29        Set-Location -Path $PSPath
[16617]30        ./TestResults -WaitToStep $WaitToStep -BenchName $BenchName -PeelCnt $PeelCnt -EvalCnt $EvalCnt -InitMethod $InitMethod -GrowMethod $GrowMethod -NoClear:$NoClear -UseExisting:$UseExisting *>&1
31        Write-Output "Gen-Return: $LASTEXITCODE"
32    } -ArgumentList $(Resolve-Path $PSScriptRoot), $WaitToStep, $BenchName, $PeelCnt, $EvalCnt, $InitMethod, $GrowMethod, $NoClear.IsPresent, $UseExisting.IsPresent
[16614]33    Write-Host "Started job for $BenchName"
34}
35
36$ActiveJobs.Values | Wait-Job | Out-Null
[16618]37foreach($BenchName in $ActiveJobs.Keys | Sort-Object) {
[16614]38    $Job = $ActiveJobs[$BenchName]
39    $Res = $Job | Receive-Job
[16617]40    $ReturnLine = $Res | Select-String -SimpleMatch "Gen-Return: "
41    if($ReturnLine -match "Gen-Return: (\d+)") {
42        if($Matches[0] -ne 0) {
43            Write-Error "$($BenchName): An error occurred! Return-Code $($Matches[0])"
44            continue
45        }
46    }
[16614]47    $Succeeded = ($Res | Select-String -Pattern "^[0-9]+\sOK").Count
48    $Failed = ($Res | Select-String -Pattern "^[0-9]+\sfailed!").Count
49    if($($Succeeded + $Failed) -ne $WaitToStep ) {
[16617]50        $Missing = $WaitToStep - ($Succeeded + $Failed)
51        Write-Error "$($BenchName): $Missing steps missing, or something went wrong!? Please check manuelly"
[16614]52    }
53    if($Succeeded -eq $WaitToStep) {
[16617]54        Write-Host "$($BenchName): $Succeeded / $WaitToStep `ttests succeeded"
[16614]55    } else {
[16617]56        Write-Warning "$($BenchName): $Failed / $WaitToStep `ttests failed!"
[16614]57    }
58}
59Get-Job | Remove-Job -Force | Out-Null
Note: See TracBrowser for help on using the repository browser.