3
1

speed_test.sh 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. RESOURCES='members councils proposals channels categories threads posts blocks events eras'
  2. SLEEP=15
  3. API=/api/v1/
  4. BALANCER=https://api.joystreamstats.live
  5. SERVER1=https://frankfurt.api.joystreamstats.live
  6. SERVER2=https://helsinki.api.joystreamstats.live
  7. CURL_OPTIONS='-s -o NUL -w %{time_total}s'
  8. function now {
  9. date +%s
  10. }
  11. while [[ 1 ]] ; do
  12. printf "%15s %15s %15s %15s\n" resource balancer frankfurt helsinki
  13. for res in $RESOURCES
  14. do
  15. start=$((now))
  16. printf "Fetching $res"
  17. printf "\r%15s %15s %15s %15s" $res \
  18. `curl $BALANCER$API$res $CURL_OPTIONS` \
  19. `curl $SERVER1$API$res $CURL_OPTIONS` \
  20. `curl $SERVER2$API$res $CURL_OPTIONS`
  21. printf " %4ds\n" $((now - $start))
  22. echo $start
  23. done
  24. for res in $RESOURCES
  25. do
  26. printf "Fetching $res/1"
  27. printf "\r%15s %15s %15s %15s\n" "$res (1)" \
  28. `curl $BALANCER$API$res/1 $CURL_OPTIONS` \
  29. `curl $SERVER1$API$res/1 $CURL_OPTIONS` \
  30. `curl $SERVER2$API$res/1 $CURL_OPTIONS`
  31. done
  32. printf "%30s" "restarting in $SLEEP"
  33. sleep $SLEEP
  34. printf "\r%30s\n" ""
  35. done