-
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.
create benchmark test for send and publish
- Loading branch information
1 parent
c421848
commit e63acea
Showing
2 changed files
with
46 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package midt_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/ssengalanto/midt" | ||
) | ||
|
||
func Benchmark_Send(b *testing.B) { | ||
m := midt.New() | ||
|
||
hdlr := &CommandHandler{} | ||
err := m.RegisterRequestHandler(hdlr) | ||
if err != nil { | ||
b.Error(err) | ||
} | ||
|
||
b.ResetTimer() | ||
for i := 0; i < b.N; i++ { | ||
_, err := m.Send(context.Background(), &CommandRequest{}) | ||
if err != nil { | ||
b.Error(err) | ||
} | ||
} | ||
} | ||
|
||
func Benchmark_Publish(b *testing.B) { | ||
m := midt.New() | ||
|
||
hdlr := &NotificationHandler{} | ||
err := m.RegisterNotificationHandler(hdlr) | ||
if err != nil { | ||
b.Error(err) | ||
} | ||
|
||
b.ResetTimer() | ||
for i := 0; i < b.N; i++ { | ||
_, err := m.Send(context.Background(), &NotificationRequest{}) | ||
if err != nil { | ||
b.Error(err) | ||
} | ||
} | ||
} |
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