Browse Source

improve speed_test.sh

Joystream Stats 4 years ago
parent
commit
6d143761cb
1 changed files with 14 additions and 5 deletions
  1. 14 5
      speed_test.sh

+ 14 - 5
speed_test.sh

@@ -7,21 +7,30 @@ SERVER2=https://helsinki.api.joystreamstats.live
 
 CURL_OPTIONS='-s -o NUL -w %{time_total}s'
 
+function now {
+  date +%s
+}
+
 while [[ 1 ]] ; do
 
 printf "%15s %15s %15s %15s\n" resource balancer frankfurt helsinki
 
 for res in $RESOURCES
 do
-  printf "%15s %15s %15s %15s\n" $res \
-   `curl $BALANCER$API$res/1 $CURL_OPTIONS` \
-   `curl $SERVER1$API$res/1 $CURL_OPTIONS` \
-   `curl $SERVER2$API$res/1 $CURL_OPTIONS`
+  start=$((now))
+  printf "Fetching $res"
+  printf "\r%15s %15s %15s %15s" $res \
+   `curl $BALANCER$API$res $CURL_OPTIONS` \
+   `curl $SERVER1$API$res $CURL_OPTIONS` \
+   `curl $SERVER2$API$res $CURL_OPTIONS`
+  printf " %4ds\n" $((now - $start))
+  echo $start
 done
 
 for res in $RESOURCES
 do
-  printf "%15s %15s %15s %15s\n" "$res (1)" \
+  printf "Fetching $res/1"
+  printf "\r%15s %15s %15s %15s\n" "$res (1)" \
    `curl $BALANCER$API$res/1 $CURL_OPTIONS` \
    `curl $SERVER1$API$res/1 $CURL_OPTIONS` \
    `curl $SERVER2$API$res/1 $CURL_OPTIONS`