Browse Source

Add speedtest-compare

cryobry 1 year ago
parent
commit
fc3b37d7ca
1 changed files with 33 additions and 0 deletions
  1. 33 0
      speedtest-compare

+ 33 - 0
speedtest-compare

@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+#
+# This script will perform speedtests over wireguard and the
+# native connections and print their output
+#
+#
+
+_speedTestData() {
+
+	local pingbps ping_f bps_f bps_int
+	export ping_int mbps_int
+
+	pingbps=$(speedtest-cli --no-upload --csv "$@" | cut -d"," -f7-8)
+	ping_f="${pingbps%,*}" # grab first value
+	ping_int="${ping_f%.*}" # make integer
+	bps_f="${pingbps#*,}" # grab second value
+	bps_int="${bps_f%.*}" # make integer
+	mbps_int=$((bps_int / 1000000)) # convert to mbps
+}
+
+# Test Wireguard using automatic server selection
+if _speedTestData; then
+	echo "Wireguard:"
+	echo -e "\tPing: $ping_int"
+	echo -e "\tMbps: $mbps_int"
+fi
+
+# Test native connection to ISP
+if _speedTestData --server 17170; then
+	echo "Native:"
+	echo -e "\tPing: $ping_int"
+	echo -e "\tMbps: $mbps_int"
+fi