Commit 571d6753 authored by luxq's avatar luxq

add benchmark

parent 7fd28581
......@@ -2,6 +2,7 @@ package payment
import (
"context"
"fmt"
"github.com/stretchr/testify/assert"
"testing"
)
......@@ -63,3 +64,24 @@ func TestPayment(t *testing.T) {
err := p.Close()
assert.NoError(t, err)
}
// add benchmark test for IncrBalance
func BenchmarkPaymentIncrBalance(b *testing.B) {
p := NewPayment(RedisConnParam{
Addr: "127.0.0.1:6379",
Password: "123456",
DbIndex: 0,
})
defer p.Close()
// run the IncrBalance function b.N times with different uid
for n := 0; n < b.N; n++ {
uid := fmt.Sprintf("11%d", n)
_, err := p.IncrBalance(context.Background(), uid, 100)
if err != nil {
b.Error(err)
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment