Skip to content

Commit

Permalink
refactor: more effective benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
siyul-park committed Dec 3, 2023
1 parent 8d95661 commit 9452c96
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
5 changes: 3 additions & 2 deletions pkg/plugin/controllx/switch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,12 @@ func BenchmarkSwitchNode_Send(b *testing.B) {
inPayload, _ := primitive.MarshalText(map[string]bool{
"a": true,
})

inPck := packet.New(inPayload)

b.ResetTimer()

for i := 0; i < b.N; i++ {
inStream.Send(packet.New(inPayload))
inStream.Send(inPck)
<-outStream.Receive()
}
}
11 changes: 7 additions & 4 deletions pkg/plugin/networkx/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,16 @@ func BenchmarkRouterNode_Send(b *testing.B) {
inStream := in.Open(proc)
outStream := out.Open(proc)

inPayload := primitive.NewMap(
primitive.NewString(KeyMethod), primitive.NewString(http.MethodGet),
primitive.NewString(KeyPath), primitive.NewString("/first"),
)
inPck := packet.New(inPayload)

b.ResetTimer()

for i := 0; i < b.N; i++ {
inStream.Send(packet.New(primitive.NewMap(
primitive.NewString(KeyMethod), primitive.NewString(http.MethodGet),
primitive.NewString(KeyPath), primitive.NewString("/first"),
)))
inStream.Send(inPck)
<-outStream.Receive()
}
}

0 comments on commit 9452c96

Please sign in to comment.