-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbenchmark-url.sh
More file actions
executable file
·36 lines (30 loc) · 876 Bytes
/
benchmark-url.sh
File metadata and controls
executable file
·36 lines (30 loc) · 876 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
# Curl a given url twice - with and without cache (no_cache=1, Magento) -
# and output the url and the response times.
#
# Example usage:
# benchmark-url.sh "https://www.example.com/"
url="$1"
if [[ $# -ne 1 ]]; then
echo "Usage: $0 url"
exit 1
fi
bold=$(tput bold)
normal=$(tput sgr0)
withoutCache() {
local url="$1"
if [[ $url == *"?"* ]]; then
echo "${url}&no_cache=1"
else
echo "${url}?no_cache=1"
fi
}
checkResponseTime() {
local url="$1"
responseTime=$(curl -s -w %{time_total}\\n -o /dev/null "$url")
echo -e "Checking response time for $url (cached) - ${bold}$responseTime${normal}"
url=$(withoutCache $url)
responseTime=$(curl -s -w %{time_total}\\n -o /dev/null "${url}")
echo -e "Checking response time for $url (not cached) - ${bold}$responseTime${normal}"
}
checkResponseTime $url