Skip to content

Commit ed016c8

Browse files
Update batch-fragment-test.ps1
1 parent 123968a commit ed016c8

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

batch-fragment-test.ps1

+31-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@ $LOG_FILE = "C:/Workspace/pings.txt"
55

66
# Arrays of possible values for packets, length, and interval
77
$packetsOptions = @("tlshello", "1-2", "1-5")
8-
$lengthOptions = @("1-1", "1-5", "1-10", "3-5", "5-10", "3-10", "10-15", "10-20", "10-30")
9-
$intervalOptions = @("1-1", "1-5", "3-5", "5-10", "10-20", "1-10", "3-10", "10-30")
8+
$lengthOptions = @("1-1", "1-5", "1-10", "3-5", "5-10", "3-10", "10-15", "10-30", "10-20", "20-50", "50-100", "100-150")
9+
$intervalOptions = @("1-1", "1-5", "5-10", "10-20", "20-50", "40-50", "50-100", "100-150", "150-200", "100-200")
1010

11+
# Number of instances to run
12+
$Instances = 10
13+
14+
# Array to store top three lowest average response times
15+
$topThree = @()
1116

1217
# Function to randomly select a value from an array
1318
function Get-RandomValue {
@@ -65,7 +70,7 @@ Start-Sleep -Seconds 10
6570

6671
Clear-Content -Path $LOG_FILE
6772

68-
for ($i = 0; $i -lt 10; $i++) {
73+
for ($i = 0; $i -lt $Instances; $i++) {
6974
$packets = Get-RandomValue -options $packetsOptions
7075
$length = Get-RandomValue -options $lengthOptions
7176
$interval = Get-RandomValue -options $intervalOptions
@@ -74,6 +79,29 @@ for ($i = 0; $i -lt 10; $i++) {
7479
$pingResult = Curl-Test -packets $packets -length $length -interval $interval
7580
Add-Content -Path $LOG_FILE -Value $pingResult
7681
Add-Content -Path $LOG_FILE -Value "`n"
82+
83+
# Extract average response time from the result
84+
$averageResponseTime = ($pingResult -split "`n" | Where-Object { $_ -match "Average:" }) -replace "Average: " -replace " seconds", "" -as [double]
85+
86+
# Add the average response time along with fragment values to the top three list
87+
$topThree += [PSCustomObject]@{
88+
AverageResponseTime = $averageResponseTime
89+
Packets = $packets
90+
Length = $length
91+
Interval = $interval
92+
}
93+
}
94+
95+
# Sort the top three list by average response time in ascending order
96+
$sortedTopThree = $topThree | Sort-Object -Property AverageResponseTime
97+
98+
# Display the top three lowest average response times along with their corresponding fragment values
99+
Write-Host "Top three lowest average response times:"
100+
for ($i = 0; $i -lt 3; $i++) {
101+
$item = $sortedTopThree[$i]
102+
Write-Host "Average Response Time: $($item.AverageResponseTime) seconds"
103+
Write-Host "Packets: $($item.Packets), Length: $($item.Length), Interval: $($item.Interval)"
104+
Write-Host ""
77105
}
78106

79107
Stop-Process -Name "xray" -Force

0 commit comments

Comments
 (0)