File size: 1,490 Bytes
72f4be8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#! /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)"