#! /bin/env bash data_list_1() { responses=( "one hundred forty five" "twenty thousand nine hundred fifty" "one hundred forty five" "nine hundred eighty three" "five million" ) echo "${responses[$1]}" } data_list_2() { responses=( "Totally agree" "I like it" "No more" "I am not sure" "Never" ) echo "${responses[$1]}" } text2int="https://tangibleai-mathtext.hf.space/run/text2int" text2intpreprocessed="https://tangibleai-mathtext.hf.space/run/text2int-preprocessed" sentimentanalysis="https://tangibleai-mathtext.hf.space/run/sentiment-analysis" test_endpoint() { start_=$(date +%s.%N) response=$(curl --silent -X POST "$1" -H 'Content-Type: application/json' -d "$2") end_=$(date +%s.%N) diff=$(echo "$end_ - $start_" | bc) printf " endpoint:%s\n data:%s delay:%s:\n %s\n" "$1" "$2" "$diff" "$response" } echo "start: $(date)" for i in {1..20}; do random_value=$((RANDOM % 5)) text=$(data_list_1 $random_value) data='{"data": ["'$text'"]}' test_endpoint "$text2int" "$data" >>call_history.txt & done for i in {1..20}; do random_value=$((RANDOM % 5)) text=$(data_list_1 $random_value) data='{"data": ["'$text'"]}' test_endpoint "$text2intpreprocessed" "$data" >>call_history.txt & done for i in {1..20}; do random_value=$((RANDOM % 5)) text=$(data_list_2 $random_value) data='{"data": ["'$text'"]}' test_endpoint "$sentimentanalysis" "$data" >>call_history.txt & done wait echo "end: $(date)"