-
Notifications
You must be signed in to change notification settings - Fork 1
/
perf_test
executable file
·90 lines (73 loc) · 2.22 KB
/
perf_test
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $DIR/config
if ! [ -f "$QUERY" ];
then
echo "SPARQL Query file not found."
exit 0
fi
echo
#if (( $OFFSET > 0 )); then
# REQUESTS=$(($REQUESTS + $OFFSET - 1))
#else
# REQUESTS=$(($REQUESTS - 1))
#fi
# COUNT=0
URIS=()
LABELS=()
URISFILE="data/uris.csv"
COUNTER=1
COUNTER_REQUESTS=0
while IFS=',' read uri label ; do
if [[ "$uri" == "s" ]];
then
continue
fi
COUNTER=$[$COUNTER + 1]
if (( $OFFSET > $COUNTER ));
then
continue
fi
# Add URI to array
URIS+=( "$uri" )
# Add label to array
label=$(echo $label | sed 's/"//g')
label=$(echo $label | sed 's/\r//g')
LABELS+=( "${label}" )
COUNTER_REQUESTS=$[$COUNTER_REQUESTS + 1]
if (( $COUNTER_REQUESTS > $REQUESTS ));
then
break
fi
done < $URISFILE
BATCH_SIZE=20
BATCHES=$(( $REQUESTS / $BATCH_SIZE ))
for ((batch=0;batch<=$BATCHES;batch++))
do
for ((request=0;request<=$BATCH_SIZE;request++))
do
uri="${URIS[$(( $batch * $BATCH_SIZE + $request ))]}"
label="${LABELS[$(( $batch * $BATCH_SIZE + $request ))]}"
if [[ "$QUERY" == *"unknown-relations"* ]];
then
echo "$uri -- $label"
curl $AUTHMETHOD --user "$MLUSER:$MLPASS" -X POST \
--data-urlencode query@$QUERY \
--data-urlencode "database=$DB" \
--data-urlencode "bind:resource_uri=$uri" \
--data-urlencode "bind:resource_label@en=$label" \
-H "Content-type: application/x-www-form-urlencoded" \
-H "Accept: application/sparql-results+xml" \
http://$MLHOST:$MLPORT/v1/graphs/sparql &
elif [[ "$QUERY" == *"known-relations"* || "$QUERY" == *"simple_select"* ]];
then
echo "$uri"
curl -s $AUTHMETHOD --user "$MLUSER:$MLPASS" -X POST \
--data-binary @$QUERY \
-H "Content-type: application/sparql-query" \
-H "Accept: application/sparql-results+xml" \
"http://$MLHOST:$MLPORT/v1/graphs/sparql?database=$DB&bind:resource_uri=$uri" &
fi
done
wait
done