-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-perf-test.sh
executable file
·73 lines (58 loc) · 2.22 KB
/
run-perf-test.sh
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
#!/bin/bash
# Run performance tests
#
# Usage:
# ./run-perf-test.sh http://admin:admin@localhost:5984
COUCHDB_URL="$1"
TESTS_COUNT=50
BATCH_SIZE=10000
IDS_COUNT=20000
# format time output
TIMEFORMAT='%3E'
# payloads
ids=$(
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n $IDS_COUNT | xargs -I UUID echo '"UUID"'
)
doc_ids_payload=$(
echo "$ids" | jq -s '{ doc_ids: . }'
)
# in_selector_payload=$(
# echo "$ids" | jq -s '{ selector: { _id: { "$in": . } } }'
# )
gt_selector_payload='{"selector": { "_id": { "$gt": "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" } }}'
regex_selector_payload='{"selector": { "_id": { "$regex": "customer:(xlmKxDZHhCQfOd1HfyIdHbJbKfENirby|BGZwRWRyLIZBanxSAI1AOiPXnB4Rbn7D|kwZGGmF7qt6TEhIJYaaE6L24fO0clKWK)" } }}'
# setup database 'perf'
curl -XDELETE --silent "$COUCHDB_URL/perf" > /dev/null
curl -XPUT --silent "$COUCHDB_URL/perf" > /dev/null
for (( i=1; i<=$TESTS_COUNT; i++ ))
do
docs_count=$(($i * $BATCH_SIZE / 1000))
# upload docs
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n $BATCH_SIZE \
| xargs -I UUID echo '{"_id":"UUID"}' \
| jq -s '{ docs: . }' \
| curl -XPOST --silent "$COUCHDB_URL/perf/_bulk_docs" -H 'Content-Type:application/json' -d @- \
> /dev/null
doc_ids_time=$(
{
time echo "$doc_ids_payload" | curl -XPOST --silent "$COUCHDB_URL/perf/_changes?filter=_doc_ids" -H 'Content-Type:application/json' -d @- > /dev/null;
} 2>&1
)
# in_selector_time=$(
# {
# time echo "$in_selector_payload" | curl -XPOST --silent "$COUCHDB_URL/perf/_changes?filter=_selector" -H 'Content-Type:application/json' -d @- > /dev/null;
# } 2>&1
# )
gt_selector_time=$(
{
time echo "$gt_selector_payload" | curl -XPOST --silent "$COUCHDB_URL/perf/_changes?filter=_selector" -H 'Content-Type:application/json' -d @- > /dev/null;
} 2>&1
)
regex_selector_time=$(
{
time echo "$regex_selector_payload" | curl -XPOST --silent "$COUCHDB_URL/perf/_changes?filter=_selector" -H 'Content-Type:application/json' -d @- > /dev/null;
} 2>&1
)
# echo "$docs_count, $doc_ids_time, $in_selector_time, $gt_selector_time, $regex_selector_time"
echo "$docs_count, $doc_ids_time, $gt_selector_time, $regex_selector_time"
done