Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,26 @@ jobs:
exit 1
}

# Run all test .bat files
# Run all test .bat and .ps1 files
$env:force_ansi = 1

# Run .bat files
Get-ChildItem -Path tests -Recurse -Filter *.bat | ForEach-Object {
Write-Host "Running test: $($_.FullName)"
& $_.FullName

if ($LASTEXITCODE -ne 0) {
Write-Error "Test failed: $($_.FullName)"
exit 1
}
}

# Run .ps1 files
Get-ChildItem -Path tests -Recurse -Filter *.ps1 | ForEach-Object {
Write-Host "Running test: $($_.FullName)"
& $_.FullName
if ($LASTEXITCODE -ne 0) {
Write-Error "Test failed: $($_.FullName)"
exit 1
}
}

22 changes: 22 additions & 0 deletions tests/performance/perf_help.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Performance test for help command
# Measures time taken to display help information

Write-Host "Testing help command performance..." -ForegroundColor Yellow

# Warm-up run
& win-witr --help | Out-Null

# Measure performance
$result = Measure-Command {
& win-witr --help | Out-Null
}

Write-Host "Performance: Help command took $($result.TotalMilliseconds)ms" -ForegroundColor Cyan

# Verify it worked
if ($LASTEXITCODE -ne 0) {
Write-Error "Help command failed"
exit 1
}

exit 0
22 changes: 22 additions & 0 deletions tests/performance/perf_pid_100runs.ps1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need to use the pid i just meant to use like the 100 iterations things but you should use the name way which can automatically get the pid for you

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in cb8dac4 - now uses win-witr win-witr.exe which automatically finds the PID by process name.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Performance test for process lookup - 100 iterations
# Measures time taken for each execution to look up a process by name

Write-Host "Testing process lookup performance over 100 iterations..." -ForegroundColor Yellow

# Verify win-witr works before starting measurements
& win-witr win-witr.exe | Out-Null
if ($LASTEXITCODE -ne 0) {
Write-Error "win-witr process lookup failed"
exit 1
}

# Run 100 iterations and measure each
Write-Host "Running 100 iterations of win-witr win-witr.exe..." -ForegroundColor Cyan
1..100 | ForEach-Object {
Measure-Command {
& win-witr win-witr.exe | Out-Null
} | Select-Object TotalMilliseconds
}

Write-Host "Performance test completed successfully!" -ForegroundColor Green
exit 0
33 changes: 33 additions & 0 deletions tests/performance/perf_pid_lookup.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Performance test for PID lookup
# Measures time taken to look up a process by PID

Write-Host "Testing PID lookup performance..." -ForegroundColor Yellow

# Get current PowerShell PID
$currentPid = $PID

# Warm-up run
& win-witr $currentPid | Out-Null

# Measure performance - average of 5 runs
$measurements = @()
for ($i = 1; $i -le 5; $i++) {
$result = Measure-Command {
& win-witr $currentPid | Out-Null
}
$measurements += $result.TotalMilliseconds
}

$average = ($measurements | Measure-Object -Average).Average
$min = ($measurements | Measure-Object -Minimum).Minimum
$max = ($measurements | Measure-Object -Maximum).Maximum

Write-Host "Performance: PID lookup took avg=$([Math]::Round($average, 2))ms, min=$([Math]::Round($min, 2))ms, max=$([Math]::Round($max, 2))ms" -ForegroundColor Cyan

# Verify it worked
if ($LASTEXITCODE -ne 0) {
Write-Error "PID lookup failed"
exit 1
}

exit 0
30 changes: 30 additions & 0 deletions tests/performance/perf_self_lookup.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Performance test for process lookup
# Measures time taken to look up the win-witr process itself

Write-Host "Testing process lookup performance..." -ForegroundColor Yellow

# Warm-up run
& win-witr win-witr.exe | Out-Null

# Measure performance - average of 5 runs
$measurements = @()
for ($i = 1; $i -le 5; $i++) {
$result = Measure-Command {
& win-witr win-witr.exe | Out-Null
}
$measurements += $result.TotalMilliseconds
}

$average = ($measurements | Measure-Object -Average).Average
$min = ($measurements | Measure-Object -Minimum).Minimum
$max = ($measurements | Measure-Object -Maximum).Maximum

Write-Host "Performance: Process lookup took avg=$([Math]::Round($average, 2))ms, min=$([Math]::Round($min, 2))ms, max=$([Math]::Round($max, 2))ms" -ForegroundColor Cyan

# Verify it worked
if ($LASTEXITCODE -ne 0) {
Write-Error "Process lookup failed"
exit 1
}

exit 0
22 changes: 22 additions & 0 deletions tests/performance/perf_version.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Performance test for version command
# Measures time taken to display version information

Write-Host "Testing version command performance..." -ForegroundColor Yellow

# Warm-up run
& win-witr --version | Out-Null

# Measure performance
$result = Measure-Command {
& win-witr --version | Out-Null
}

Write-Host "Performance: Version command took $($result.TotalMilliseconds)ms" -ForegroundColor Cyan

# Verify it worked
if ($LASTEXITCODE -ne 0) {
Write-Error "Version command failed"
exit 1
}

exit 0
9 changes: 0 additions & 9 deletions tests/performance/stess_nested_shells.bat

This file was deleted.

19 changes: 12 additions & 7 deletions tests/performance/stress_nested_shells.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,28 @@ param(
[int]$CurrentDepth = 0,
[string]$CurrentShell = "powershell"
)
cd D:\a\win-witr\win-witr
# Ensure win-witr.exe is in PATH or current directory

# Find the script directory and navigate to repository root
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$repoRoot = Split-Path -Parent (Split-Path -Parent $scriptDir)
Set-Location $repoRoot

# Verify win-witr.exe is accessible
if (-not (Test-Path "win-witr.exe" -PathType Leaf) -and -not (Get-Command "win-witr" -ErrorAction SilentlyContinue)) {
Write-Error "win-witr.exe not found in current directory or PATH"
exit 1
}

if ($CurrentDepth -ge $MaxDepth) {
# We've reached max depth - run the actual test
Write-Host "Reached depth $CurrentDepth - Running stress test..." -ForegroundColor Green

# Run the measurement
cd D:\a\win-witr\win-witr
.\win-witr win-witr.exe
$result = Measure-Command {

.\win-witr win-witr.exe
& win-witr win-witr.exe | Out-Null
}

Write-Host "Time taken at depth ${CurrentDepth}: $($result.TotalMilliseconds)ms" -ForegroundColor Cyan
Write-Host "Performance: Nested shell lookup at depth $CurrentDepth took $($result.TotalMilliseconds)ms" -ForegroundColor Cyan

# Verify it actually worked
if ($LASTEXITCODE -ne 0) {
Expand Down