~hacktivista/config

8177dd904ca8c380f43655de93ec63510596dc64 — Felix Freeman 6 months ago ea954ab
Simple speedtest for comparing download URLs
1 files changed, 21 insertions(+), 0 deletions(-)

A root/usr/local/bin/speedtest
A root/usr/local/bin/speedtest => root/usr/local/bin/speedtest +21 -0
@@ 0,0 1,21 @@
#!/bin/sh

# Copyright (c) 2023 Felix Freeman <libsys@hacktivista.org>
#
# This software is licensed under the 'MIT No Attribution' license terms. I
# don't want attribution nor exclusive rights over it, but I'd love that you
# free your software too.

if [ "$1" = '-h' ]; then
	echo 'Test download times for a list of URLs'
	echo "Usage: cat <urls-file> | $(basename $0) [timeout=2]"
	exit 1
fi

timeout=${1:-2}
urls=$(cat)

for url in $urls; do
	time="$(curl -m $timeout -sf -w %{time_total} -o /dev/null $url)"
	printf "%s %s\n" $time $url
done