-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.ps1
More file actions
80 lines (64 loc) · 2.41 KB
/
run_tests.ps1
File metadata and controls
80 lines (64 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Script to run all tests and save results to the test_results folder.
# Usage: .\run_tests.ps1 [-BuildDir build] [-Configuration Release]
param(
[string]$BuildDir = "build",
[string]$Configuration = "Release"
)
$ErrorActionPreference = "Stop"
$RepoRoot = $PSScriptRoot
function Resolve-BinaryPath {
param(
[string]$Name,
[string]$Kind = "root"
)
$candidates = if ($Kind -eq "bin") {
@(
(Join-Path $RepoRoot "$BuildDir\bin\$Configuration\$Name.exe"),
(Join-Path $RepoRoot "$BuildDir\bin\$Name.exe")
)
} else {
@(
(Join-Path $RepoRoot "$BuildDir\$Configuration\$Name.exe"),
(Join-Path $RepoRoot "$BuildDir\$Name.exe")
)
}
foreach ($candidate in $candidates) {
if (Test-Path $candidate) {
return $candidate
}
}
throw "Could not find $Name.exe under $BuildDir (configuration '$Configuration')."
}
$testDir = Join-Path $RepoRoot "test_results"
if (-not (Test-Path $testDir)) {
New-Item -ItemType Directory -Path $testDir | Out-Null
}
$spmvExe = Resolve-BinaryPath -Name "test_spmv"
$cgExe = Resolve-BinaryPath -Name "test_cg"
$solveExe = Resolve-BinaryPath -Name "solve" -Kind "bin"
Write-Host "Running tests and saving results to $testDir..." -ForegroundColor Green
Write-Host ""
Write-Host "Running SpMV test..." -ForegroundColor Cyan
& $spmvExe > (Join-Path $testDir "test_results_spmv.txt") 2>&1
Write-Host "Running CG test..." -ForegroundColor Cyan
& $cgExe > (Join-Path $testDir "test_results_cg.txt") 2>&1
Write-Host ""
Write-Host "Running solver benchmarks..." -ForegroundColor Green
Write-Host ""
$configs = @(
@{nx = 64; ny = 64; tol = "1e-6"; maxiters = 1000},
@{nx = 128; ny = 128; tol = "1e-8"; maxiters = 5000},
@{nx = 256; ny = 256; tol = "1e-10"; maxiters = 10000}
)
foreach ($config in $configs) {
$nx = $config.nx
$ny = $config.ny
$tol = $config.tol
$maxiters = $config.maxiters
$filename = "solve_results_nx${nx}_ny${ny}_tol${tol}_maxiters${maxiters}.txt"
Write-Host "Running solve --nx $nx --ny $ny --tol $tol --max-iters $maxiters" -ForegroundColor Cyan
& $solveExe --nx $nx --ny $ny --tol $tol --max-iters $maxiters > (Join-Path $testDir $filename) 2>&1
}
Write-Host ""
Write-Host "All tests completed. Results saved in $testDir." -ForegroundColor Green
Get-ChildItem $testDir | Format-Table Name, Length, LastWriteTime -AutoSize