From 6a2613a48e96810fd1383a51908433da4d9c5a55 Mon Sep 17 00:00:00 2001 From: "Dominik.Sigmund" <dominik.sigmund@br.de> Date: Thu, 10 Oct 2024 12:17:10 +0200 Subject: [PATCH] Added Download-Time --- .vscode/settings.json | 5 +++++ README.md | 8 ++++---- sparrow.ps1 | 7 ++++--- sparrow.sh | 9 +++++---- 4 files changed, 18 insertions(+), 11 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..8a049e0 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "[markdown]": { + "editor.cursorSurroundingLines": 0 + } +} \ No newline at end of file diff --git a/README.md b/README.md index d21c6e3..9cd2149 100644 --- a/README.md +++ b/README.md @@ -99,16 +99,16 @@ Run the script with the desired options: The script generates a CSV file (`curl_report.csv`) with the following columns: ```csv -timestamp;url;ttfb;total;client;user;network +timestamp;url;ttfb;download;total;client;user;network ``` ### Example csv output: ```csv timestamp;url;ttfb;total;client;user;network -2024-10-09 15:30:45;https://mywebsite.com/style.css;0.056;0.230;client_xyz;user_jane;WiFi -2024-10-09 15:30:48;https://mywebsite.com/image.png;0.078;0.315;client_xyz;user_jane;WiFi -2024-10-09 15:31:45;https://mywebsite.com/style.css;0.058;0.225;client_xyz;user_jane;WiFi +2024-10-09 15:30:45;https://mywebsite.com/style.css;0.056;0.234:0.230;client_xyz;user_jane;WiFi +2024-10-09 15:30:48;https://mywebsite.com/image.png;0.078;0.234;0.315;client_xyz;user_jane;WiFi +2024-10-09 15:31:45;https://mywebsite.com/style.css;0.058;0.123;0.225;client_xyz;user_jane;WiFi ... ``` diff --git a/sparrow.ps1 b/sparrow.ps1 index b9ae3c0..a5e38d9 100644 --- a/sparrow.ps1 +++ b/sparrow.ps1 @@ -27,11 +27,12 @@ function Perform-Curl { $outputParts = $curlOutput -split ';' $ttfb = $outputParts[0] $totalTime = $outputParts[1] + $downloadTime = [math]::Round(($totalTime - $ttfb), 3) # Append results to the CSV file - Add-Content $outputFile "$timestamp;$url;$ttfb;$totalTime;$client;$user;$network" + Add-Content $outputFile "$timestamp;$url;$ttfb;$downloadTime;$totalTime;$client;$user;$network" - Write-Host "$fileType - Iteration $iteration: TTFB: $ttfb, Total Time: $totalTime" + Write-Host "$fileType - Iteration $iteration: TTFB: $ttfb, DownloadTime: $downloadTime; Total Time: $totalTime" } # Function to get a random sleep duration between MIN and MAX @@ -57,7 +58,7 @@ $cssUrl = "$u/$cssUrl" $pngUrl = "$u/$pngUrl" # Initialize the CSV report with headers -Add-Content $outputFile "timestamp;url;ttfb;total;client;user;network" +Add-Content $outputFile "timestamp;url;ttfb;download;total;client;user;network" # Loop through the number of repetitions for ($i = 1; $i -le $r; $i++) { diff --git a/sparrow.sh b/sparrow.sh index 26d565d..2bfce16 100755 --- a/sparrow.sh +++ b/sparrow.sh @@ -32,11 +32,12 @@ perform_curl() { ttfb=$(echo "$curl_output" | cut -d ';' -f 1) total_time=$(echo "$curl_output" | cut -d ';' -f 2) - + download_time=$(awk "BEGIN {print $total_time - $ttfb}") + # Append results to the CSV file - echo "$timestamp;$url;$ttfb;$total_time;$client;$user;$network" >> "$output_file" + echo "$timestamp;$url;$ttfb;$download_time;$total_time;$client;$user;$network" >> "$output_file" - echo "$file_type - Iteration $iteration: TTFB: $ttfb, Total Time: $total_time" + echo "$file_type - Iteration $iteration: TTFB: $ttfb, DownloadTime: $download_time, Total Time: $total_time" } # Function to get a random sleep duration between MIN and MAX @@ -66,7 +67,7 @@ css_url="${base_url}/$css_url" png_url="${base_url}/$png_url" # Initialize the CSV report with headers -echo "timestamp;url;ttfb;total;client;user;network" > "$output_file" +echo "timestamp;url;ttfb;download;total;client;user;network" > "$output_file" # Loop through the number of repetitions for ((i=1; i<=repetitions; i++)) -- GitLab