Enhance monitoring features and UI:

- Add detailed CPU core monitoring option for better performance control
- Update monitoring settings in app configuration
- Improve parallel task execution for resource usage monitoring
- Modify Telegram notification service to skip alerts from svchost processes
- Add "Memory %" column to process table in HTML and update related JavaScript
- Create performance test scripts for API response time evaluation
This commit is contained in:
Din
2025-08-08 16:19:45 +08:00
parent bb7c4c3d0e
commit 3d1c55468b
10 changed files with 236 additions and 34 deletions
+56
View File
@@ -0,0 +1,56 @@
# Performance test script for ResourceUsage API
Write-Host "Waiting for service to start..." -ForegroundColor Yellow
Start-Sleep -Seconds 5
Write-Host "Testing API response time..." -ForegroundColor Green
$times = @()
$errors = 0
for ($i = 1; $i -le 5; $i++) {
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
try {
$response = Invoke-WebRequest -Uri "http://localhost:5000/api/resource/usage" -UseBasicParsing -TimeoutSec 30
$stopwatch.Stop()
$time = $stopwatch.ElapsedMilliseconds
$times += $time
Write-Host "Test $i - Response time: ${time}ms - Status: $($response.StatusCode)" -ForegroundColor Cyan
# Show first response content for verification
if ($i -eq 1) {
$jsonContent = $response.Content | ConvertFrom-Json
Write-Host "Sample response - CPU Usage: $($jsonContent.CPU.Usage)%" -ForegroundColor White
}
}
catch {
$stopwatch.Stop()
$errors++
Write-Host "Test $i - Error after $($stopwatch.ElapsedMilliseconds)ms: $($_.Exception.Message)" -ForegroundColor Red
}
if ($i -lt 5) {
Start-Sleep -Seconds 2
}
}
if ($times.Count -gt 0) {
$avgTime = ($times | Measure-Object -Average).Average
$minTime = ($times | Measure-Object -Minimum).Minimum
$maxTime = ($times | Measure-Object -Maximum).Maximum
Write-Host "`nPerformance Results:" -ForegroundColor Green
Write-Host " Average response time: $([math]::Round($avgTime, 2))ms" -ForegroundColor White
Write-Host " Minimum response time: ${minTime}ms" -ForegroundColor White
Write-Host " Maximum response time: ${maxTime}ms" -ForegroundColor White
Write-Host " Successful requests: $($times.Count)/5" -ForegroundColor White
Write-Host " Failed requests: $errors/5" -ForegroundColor White
if ($avgTime -lt 1000) {
Write-Host "✅ Performance looks good!" -ForegroundColor Green
} elseif ($avgTime -lt 3000) {
Write-Host "⚠️ Performance is acceptable but could be better" -ForegroundColor Yellow
} else {
Write-Host "❌ Performance needs improvement" -ForegroundColor Red
}
} else {
Write-Host "❌ All requests failed!" -ForegroundColor Red
}