@@ -5,9 +5,14 @@ $LOG_FILE = "C:/Workspace/pings.txt"
5
5
6
6
# Arrays of possible values for packets, length, and interval
7
7
$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 " )
10
10
11
+ # Number of instances to run
12
+ $Instances = 10
13
+
14
+ # Array to store top three lowest average response times
15
+ $topThree = @ ()
11
16
12
17
# Function to randomly select a value from an array
13
18
function Get-RandomValue {
@@ -65,7 +70,7 @@ Start-Sleep -Seconds 10
65
70
66
71
Clear-Content - Path $LOG_FILE
67
72
68
- for ($i = 0 ; $i -lt 10 ; $i ++ ) {
73
+ for ($i = 0 ; $i -lt $Instances ; $i ++ ) {
69
74
$packets = Get-RandomValue - options $packetsOptions
70
75
$length = Get-RandomValue - options $lengthOptions
71
76
$interval = Get-RandomValue - options $intervalOptions
@@ -74,6 +79,29 @@ for ($i = 0; $i -lt 10; $i++) {
74
79
$pingResult = Curl- Test - packets $packets - length $length - interval $interval
75
80
Add-Content - Path $LOG_FILE - Value $pingResult
76
81
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 " "
77
105
}
78
106
79
107
Stop-Process - Name " xray" - Force
0 commit comments