-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5135 from thesan/feature/qn-benchmark
Add a really simple QN benchmarking script
- Loading branch information
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/bin/sh | ||
|
||
# Run for T seconds | ||
T=60 | ||
|
||
# Pass the endpoint as the first argument, default to local | ||
endpoint=${1:-'http://localhost:8081/graphql'} | ||
|
||
invalidWhen=".errors != null or (.data.proposals | length == 0)" | ||
query=$( | ||
cat <<EOF | awk '{ print NR == 1 ? "" : "\\n" } 1' ORS='' | ||
{"query":"{ | ||
proposals ( | ||
# Check filter/order performance too | ||
where: { status_json: { isTypeOf_eq: \"ProposalStatusExecuted\" } } | ||
orderBy: createdAt_DESC | ||
) { | ||
id | ||
createdInEvent { id inBlock } | ||
status { __typename } | ||
creator { | ||
createdAt | ||
referredMembers { id } | ||
proposalvotedeventvoter { | ||
id | ||
inBlock | ||
} | ||
} | ||
proposalStatusUpdates { | ||
type | ||
} | ||
votes { | ||
inBlock | ||
voteKind | ||
rationale | ||
} | ||
} | ||
}"} | ||
EOF | ||
) | ||
|
||
SEC=1000000000 | ||
i=-1 | ||
|
||
until=$(($(date +%s%N) + $T * $SEC)) | ||
while [ $(date +%s%N) -lt $until ]; do | ||
i=$((i + 1)) | ||
res=$(curl -s "$endpoint" -H 'Content-Type: application/json' --data-binary "$query") | ||
if $(echo "$res" | jq -e "$invalidWhen"); then | ||
echo "Failed with response $res" | ||
exit 1 | ||
fi | ||
done | ||
|
||
echo "Sent $i queries in $T seconds" |