Skip to content

Commit ac91844

Browse files
committed
Improved error detection when CPU usage was too low.
1 parent b081443 commit ac91844

File tree

1 file changed

+50
-12
lines changed

1 file changed

+50
-12
lines changed

script-corecycler.ps1

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3014,11 +3014,15 @@ function Test-ProcessUsage {
30143014

30153015
# Does the stress test process still exist?
30163016
$checkProcess = Get-Process -Id $stressTestProcessId -ErrorAction Ignore
3017+
3018+
# What type of error occurred (PROCESSMISSING, FATALERROR, CPULOAD)
3019+
$errorType = $null
30173020

30183021

30193022
# 1. The process doesn't exist anymore, immediate error
30203023
if (!$checkProcess) {
30213024
$stressTestError = 'The ' + $selectedStressTestProgram + ' process doesn''t exist anymore.'
3025+
$errorType = 'PROCESSMISSING'
30223026
}
30233027

30243028

@@ -3032,6 +3036,7 @@ function Test-ProcessUsage {
30323036
if ($primeErrorResults.Length -gt 0) {
30333037
# We don't need to check for a false alarm anymore, as we're already checking only new log entries
30343038
$stressTestError = $primeErrorResults.Line
3039+
$errorType = 'FATALERROR'
30353040

30363041
Write-Verbose($timestamp)
30373042
Write-Verbose('Found an error in the new entries of the results.txt!')
@@ -3058,6 +3063,7 @@ function Test-ProcessUsage {
30583063
if ($primeErrorResults.Length -gt 0) {
30593064
# We don't need to check for a false alarm anymore, as we're already checking only new log entries
30603065
$stressTestError = $primeErrorResults.Line
3066+
$errorType = 'FATALERROR'
30613067
}
30623068
}
30633069

@@ -3100,16 +3106,19 @@ function Test-ProcessUsage {
31003106
}
31013107

31023108
else {
3103-
# Set the error variable if $maxChecks has been reached
3104-
if ($curCheck -eq $maxChecks) {
3109+
if ($curCheck -lt $maxChecks) {
3110+
Write-Verbose(' still not enough usage (#' + $curCheck + ')')
3111+
}
3112+
3113+
# Reached the maximum amount of checks for the CPU usage
3114+
else {
31053115
Write-Verbose(' still not enough usage, throw an error')
31063116

31073117
# We don't care about an error string here anymore
3108-
$stressTestError = 'The ' + $selectedStressTestProgram + ' process doesn''t use enough CPU power anymore (only ' + $thisProcessCPUPercentage + '% instead of the expected ' + $expectedUsageTotal + '%)'
3109-
}
3110-
else {
3111-
Write-Verbose(' still not enough usage (#' + $curCheck + ')')
3118+
$stressTestError = 'The ' + $selectedStressTestProgram + ' process doesn''t use enough CPU power anymore (only ' + $thisProcessCPUPercentage + '% instead of the expected ' + $expectedUsageTotal + '%)'
3119+
$errorType = 'CPULOAD'
31123120
}
3121+
31133122
}
31143123
}
31153124
}
@@ -3120,6 +3129,7 @@ function Test-ProcessUsage {
31203129
# We now have an error message, process
31213130
if ($stressTestError) {
31223131
Write-Verbose('There has been an error with the stress test program!')
3132+
Write-Verbose('Error type: ' + $errorType)
31233133

31243134
# Store the core number in the array
31253135
$Script:coresWithError += $coreNumber
@@ -3141,6 +3151,28 @@ function Test-ProcessUsage {
31413151
}
31423152

31433153

3154+
# If running Prime95, make one additional check if the result.txt now has an error entry
3155+
if ($isPrime95 -and $errorType -ne "FATALERROR") {
3156+
$timestamp = Get-Date -format HH:mm:ss
3157+
3158+
Write-Verbose($timestamp + ' - The stress test program is Prime95, trying to look for an error message in the results.txt')
3159+
3160+
Get-Prime95LogfileEntries
3161+
3162+
# Look for a line with an "error" string in the new log entries
3163+
$primeErrorResults = $newLogEntries | Where-Object {$_.Line -match '.*error.*'} | Select -Last 1
3164+
3165+
# Found the "error" string
3166+
if ($primeErrorResults.Length -gt 0) {
3167+
# We don't need to check for a false alarm anymore, as we're already checking only new log entries
3168+
$stressTestError = $primeErrorResults.Line
3169+
3170+
Write-Verbose($timestamp)
3171+
Write-Verbose(' Now found an error in the new entries of the results.txt!')
3172+
}
3173+
}
3174+
3175+
31443176
# Put out an error message
31453177
$timestamp = Get-Date -format HH:mm:ss
31463178
Write-ColorText('ERROR: ' + $timestamp) Magenta
@@ -3152,8 +3184,6 @@ function Test-ProcessUsage {
31523184
# Try to get more detailed error information
31533185
# Prime95
31543186
if ($isPrime95) {
3155-
Write-Verbose('The stress test program is Prime95, trying to look for an error message in the results.txt')
3156-
31573187
# Try to determine the last run FFT size
31583188
# If the results.txt doesn't exist, assume that it was on the very first iteration
31593189
# Note: Unfortunately Prime95 randomizes the FFT sizes for anything above Large FFT sizes
@@ -3223,8 +3253,12 @@ function Test-ProcessUsage {
32233253
}
32243254

32253255
Write-Verbose('The last 5 entries in the results.txt:')
3226-
$lastFiveRows | % {
3227-
Write-Verbose('- [Line ' + $_.LineNumber + '] ' + $_.Line)
3256+
$lastFiveRows | ForEach-Object -Begin {
3257+
$index = $allLogEntries.Count - 5
3258+
} `
3259+
-Process {
3260+
Write-Verbose('- [Line ' + $index + '] ' + $_)
3261+
$index++
32283262
}
32293263

32303264
Write-Text('')
@@ -3251,8 +3285,12 @@ function Test-ProcessUsage {
32513285

32523286

32533287
Write-Verbose('The last 5 entries in the results.txt:')
3254-
$lastFiveRows | % {
3255-
Write-Verbose('- [Line ' + $_.LineNumber + '] ' + $_.Line)
3288+
$lastFiveRows | ForEach-Object -Begin {
3289+
$index = $allLogEntries.Count - 5
3290+
} `
3291+
-Process {
3292+
Write-Verbose('- [Line ' + $index + '] ' + $_)
3293+
$index++
32563294
}
32573295

32583296
Write-Text('')

0 commit comments

Comments
 (0)