Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
benchmark_test.go 874 Bytes
Copy Edit Raw Blame History
Inhere authored 2022-04-14 23:52 . fix: fix tests error, add more tests
package event_test
import (
"testing"
"github.com/gookit/event"
)
func BenchmarkManager_Fire_no_listener(b *testing.B) {
em := event.NewManager("test")
em.On("app.up", event.ListenerFunc(func(e event.Event) error {
return nil
}))
b.ResetTimer()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_, _ = em.Fire("app.up", nil)
}
}
func BenchmarkManager_Fire_normal(b *testing.B) {
em := event.NewManager("test")
em.On("app.up", event.ListenerFunc(func(e event.Event) error {
return nil
}))
b.ResetTimer()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_, _ = em.Fire("app.up", nil)
}
}
func BenchmarkManager_Fire_wildcard(b *testing.B) {
em := event.NewManager("test")
em.On("app.*", event.ListenerFunc(func(e event.Event) error {
return nil
}))
b.ResetTimer()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_, _ = em.Fire("app.up", nil)
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化