forked from ReactiveX/RxPY
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b333440
commit 8574dfe
Showing
3 changed files
with
117 additions
and
5 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
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
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,109 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script runs a subset of unit tests (minus concurrency, which does too | ||
# much hard sleeps to be a useful benchmark) a couple of times, averaging the | ||
# durations as parsed from pytest output. | ||
# | ||
# It does this for each commit-ish passed as commandline arguments, and then | ||
# for the situation we were in when invoked. | ||
# | ||
# Note that this script switches the local git branch. To protect any unsaved | ||
# work when running locally, it does a git stash first, which is popped back | ||
# later. But if you kill the script before it's done, you may end up in | ||
# the wrong branch and/or your work stashed! | ||
|
||
testargs="--cache-clear --ignore=tests/test_concurrency" | ||
rounds=2 | ||
|
||
pop=0 | ||
stat=$(git status | head -n 1) | ||
head=$(echo "$stat" | grep -o "[^ ]*$") | ||
refs=$* | ||
|
||
if [[ "$TRAVIS" ]] | ||
then | ||
|
||
# Compare versus the PR target branch, if any, or just "master" otherwise | ||
if [[ "$TRAVIS_PULL_REQUEST" != false ]] | ||
then | ||
head=$(git log -1 --format=%H) | ||
refs="$TRAVIS_BRANCH" | ||
else | ||
head="$TRAVIS_BRANCH" | ||
refs=master | ||
fi | ||
|
||
else | ||
|
||
# Running locally: save unsaved work, if any | ||
if [[ "$refs" ]] | ||
then | ||
git stash | grep "^No" | ||
pop=$? | ||
fi | ||
|
||
if [[ $(echo "$stat" | grep -v " detached at ") ]] | ||
then | ||
head=$(echo "$stat" | grep -o "[^ ]*$") | ||
fi | ||
|
||
fi | ||
|
||
echo "head $head" | ||
echo "refs $refs" | ||
echo "stat $stat" | ||
echo "travis branch $TRAVIS_BRANCH" | ||
|
||
|
||
for branch in $refs $head | ||
do | ||
|
||
# Checkout the branch / commit | ||
echo "" | ||
if [[ "$TRAVIS" && "$branch" != "$head" ]] | ||
then | ||
git fetch origin $branch | ||
git checkout origin/"$branch" | ||
else | ||
git checkout "$branch" | ||
if [[ $pop != 0 ]]; then git stash pop; fi | ||
fi | ||
|
||
# Do one warm-up round, which doesn't count toward the average | ||
echo -n " - Round 0 (warm-up)" | ||
sec=$(pytest $testargs | grep -o "passed in .* s") | ||
ret=$? | ||
echo -n " | $sec" | ||
if [[ $ret == 0 ]]; | ||
then | ||
echo " | OK" | ||
else | ||
echo " | FAIL" | ||
exit $ret | ||
fi | ||
|
||
# Main loop | ||
sum=0 | ||
for round in $(seq $rounds) | ||
do | ||
echo -n " - Round $round of $rounds" | ||
sec=$(pytest $testargs | grep -o "passed in .* s") | ||
ret=$? | ||
echo -n " | $sec" | ||
|
||
sec=$(echo $sec | sed -e "s/[^0-9]//g") | ||
sum=$(($sum + $sec)) | ||
avg=$((((($sum * 10) / $round) + 5) / 10)) | ||
|
||
echo -n " | total $(echo $sum | sed -e "s/\([0-9]\{2\}\)$/.\1/") s" | ||
echo -n " | average $(echo $avg | sed -e "s/\([0-9]\{2\}\)$/.\1/") s" | ||
|
||
if [[ $ret == 0 ]] | ||
then | ||
echo " | OK" | ||
else | ||
echo " | FAIL" | ||
exit $ret | ||
fi | ||
done | ||
done |