mirror of
https://github.com/hibiken/asynq.git
synced 2025-04-22 00:30:17 +08:00
Update benchcmp.sh script
This commit is contained in:
parent
c31410cbc8
commit
f903cc6614
@ -3,13 +3,20 @@ if [ "${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}" != "master" ]; then
|
|||||||
cd ${TRAVIS_BUILD_DIR}/.. && \
|
cd ${TRAVIS_BUILD_DIR}/.. && \
|
||||||
git clone ${REMOTE_URL} "${TRAVIS_REPO_SLUG}-bench" && \
|
git clone ${REMOTE_URL} "${TRAVIS_REPO_SLUG}-bench" && \
|
||||||
cd "${TRAVIS_REPO_SLUG}-bench" && \
|
cd "${TRAVIS_REPO_SLUG}-bench" && \
|
||||||
|
|
||||||
# Benchmark master
|
# Benchmark master
|
||||||
|
echo "Running benchmark tests on master branch"
|
||||||
git checkout master && \
|
git checkout master && \
|
||||||
go test -run=XXX -bench=. ./... > master.txt && \
|
go test -run=XXX -bench=. -loglevel=debug ./... > master.txt && \
|
||||||
|
echo "Finished benchmark tests on master branch"
|
||||||
|
|
||||||
# Benchmark feature branch
|
# Benchmark feature branch
|
||||||
|
echo "Running benchmark tests on feature branch"
|
||||||
git checkout ${TRAVIS_COMMIT} && \
|
git checkout ${TRAVIS_COMMIT} && \
|
||||||
go test -run=XXX -bench=. ./... > feature.txt && \
|
go test -run=XXX -bench=. -loglevel=debug ./... > feature.txt && \
|
||||||
go get -u golang.org/x/tools/cmd/benchcmp && \
|
echo "Finished benchmark tests on feature branch"
|
||||||
|
|
||||||
# compare two benchmarks
|
# compare two benchmarks
|
||||||
|
go get -u golang.org/x/tools/cmd/benchcmp && \
|
||||||
benchcmp master.txt feature.txt;
|
benchcmp master.txt feature.txt;
|
||||||
fi
|
fi
|
@ -29,6 +29,7 @@ func BenchmarkEndToEndSimple(b *testing.B) {
|
|||||||
RetryDelayFunc: func(n int, err error, t *Task) time.Duration {
|
RetryDelayFunc: func(n int, err error, t *Task) time.Duration {
|
||||||
return time.Second
|
return time.Second
|
||||||
},
|
},
|
||||||
|
LogLevel: testLogLevel,
|
||||||
})
|
})
|
||||||
// Create a bunch of tasks
|
// Create a bunch of tasks
|
||||||
for i := 0; i < count; i++ {
|
for i := 0; i < count; i++ {
|
||||||
@ -72,6 +73,7 @@ func BenchmarkEndToEnd(b *testing.B) {
|
|||||||
RetryDelayFunc: func(n int, err error, t *Task) time.Duration {
|
RetryDelayFunc: func(n int, err error, t *Task) time.Duration {
|
||||||
return time.Second
|
return time.Second
|
||||||
},
|
},
|
||||||
|
LogLevel: testLogLevel,
|
||||||
})
|
})
|
||||||
// Create a bunch of tasks
|
// Create a bunch of tasks
|
||||||
for i := 0; i < count; i++ {
|
for i := 0; i < count; i++ {
|
||||||
@ -90,8 +92,16 @@ func BenchmarkEndToEnd(b *testing.B) {
|
|||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(count * 2)
|
wg.Add(count * 2)
|
||||||
handler := func(ctx context.Context, t *Task) error {
|
handler := func(ctx context.Context, t *Task) error {
|
||||||
// randomly fail 1% of tasks
|
n, err := t.Payload.GetInt("data")
|
||||||
if rand.Intn(100) == 1 {
|
if err != nil {
|
||||||
|
b.Logf("internal error: %v", err)
|
||||||
|
}
|
||||||
|
retried, ok := GetRetryCount(ctx)
|
||||||
|
if !ok {
|
||||||
|
b.Logf("internal error: %v", err)
|
||||||
|
}
|
||||||
|
// Return error from 1% of the tasks for the first attempt.
|
||||||
|
if retried == 0 && n%100 == 0 {
|
||||||
return fmt.Errorf(":(")
|
return fmt.Errorf(":(")
|
||||||
}
|
}
|
||||||
wg.Done()
|
wg.Done()
|
||||||
@ -131,6 +141,7 @@ func BenchmarkEndToEndMultipleQueues(b *testing.B) {
|
|||||||
"default": 3,
|
"default": 3,
|
||||||
"low": 1,
|
"low": 1,
|
||||||
},
|
},
|
||||||
|
LogLevel: testLogLevel,
|
||||||
})
|
})
|
||||||
// Create a bunch of tasks
|
// Create a bunch of tasks
|
||||||
for i := 0; i < highCount; i++ {
|
for i := 0; i < highCount; i++ {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user