1 Star 0 Fork 1

Gitee 极速下载 / ymratelimit

Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/maczam/ymratelimit
This repository doesn't specify license. Without author's permission, this code is only for learning and cannot be used for other purposes.
Clone or download
benchark_test.go 824 Bytes
Copy Edit Web IDE Raw Blame History
infi.he authored 2020-06-15 14:18 . first commit
package ymratelimit
import (
"github.com/juju/ratelimit"
"testing"
"time"
)
func BenchmarkYmretelimit(b *testing.B) {
rl := NewTokenBucket(time.Second, 15) // per second
b.ResetTimer()
for i := 0; i < b.N; i++ {
rl.TakeAvailable()
}
}
func BenchmarkParallelYmretelimit(b *testing.B) {
rl := NewTokenBucket(time.Second, 15) // per second
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
rl.TakeAvailable()
}
})
}
func BenchmarkJujuRatelimit(b *testing.B) {
rl := ratelimit.NewBucket(time.Second, 15)
b.ResetTimer()
for i := 0; i < b.N; i++ {
rl.TakeAvailable(1)
}
}
func BenchmarkParallelJujuRatelimit(b *testing.B) {
rl := ratelimit.NewBucket(time.Second, 15)
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
rl.TakeAvailable(1)
}
})
}

Comment ( 0 )

Sign in for post a comment

1
https://gitee.com/mirrors/ymratelimit.git
git@gitee.com:mirrors/ymratelimit.git
mirrors
ymratelimit
ymratelimit
master

Search