59 lines
1.2 KiB
Bash
59 lines
1.2 KiB
Bash
#!/bin/bash
|
|
#
|
|
|
|
# Activate Bash Strict Mode
|
|
set -euo pipefail
|
|
|
|
main() {
|
|
{
|
|
echo -e "URL\tRuns\tMin (ms)\tAvg (ms)\tMax (ms)"
|
|
for url in ${@:2}; do
|
|
get_statistics $url $1
|
|
done
|
|
} #| column -s $'\t' -t
|
|
}
|
|
|
|
get_statistics() {
|
|
# Initialice the variables
|
|
local min=1000000000
|
|
local max=0
|
|
local dur=0
|
|
|
|
# repeat for the defined counts the url calling
|
|
for i in $(seq 1 $2); do
|
|
local gp=$(($(get_posts $1)/1000000)) # from ns to ms
|
|
if [[ $gp -gt $max ]]
|
|
then max=$gp
|
|
fi
|
|
if [[ $gp -lt $min ]]
|
|
then min=$gp
|
|
fi
|
|
dur=$(( $dur + $gp ))
|
|
done
|
|
|
|
# output the statistic values
|
|
echo -e "$1\t$2\t$min\t$(($dur/$2))\t$max"
|
|
}
|
|
|
|
get_posts() {
|
|
# Call the url with measure time
|
|
local start=$(date +%s%N)
|
|
curl --silent --show-error $1 > /dev/null
|
|
local stop=$(date +%s%N)
|
|
local dur=$(($stop-$start))
|
|
echo $dur
|
|
}
|
|
|
|
# the main domain
|
|
hostname="https://briefedition.wedekind.h-da.de"
|
|
|
|
# the Array of the Urls
|
|
url_arr=(
|
|
"$hostname/index.xhtml"
|
|
"$hostname/view/document/list.xhtml"
|
|
"$hostname/view/correspondent/list.xhtml"
|
|
"$hostname/view/person/list.xhtml"
|
|
)
|
|
|
|
# Execute all the URLs for 10 rounds
|
|
main 10 ${url_arr[@]}
|