-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathbench_test.go
More file actions
37 lines (33 loc) · 731 Bytes
/
bench_test.go
File metadata and controls
37 lines (33 loc) · 731 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package fatchan
import (
"net"
"testing"
)
func discard(sid, cid uint64, err error) {}
func BenchmarkE2E(b *testing.B) {
for i := 0; i < b.N; i++ {
a, b := net.Pipe()
axport, bxport := New(a, discard), New(b, discard)
ach, bch := make(chan string), make(chan string)
axport.FromChan(ach)
bxport.ToChan(bch)
ach <- "test"
<-bch
axport.Close()
bxport.Close()
}
}
func BenchmarkSend(bench *testing.B) {
a, b := net.Pipe()
axport, bxport := New(a, discard), New(b, discard)
ach, bch := make(chan string), make(chan string)
axport.FromChan(ach)
bxport.ToChan(bch)
bench.SetBytes(int64(len("\x01\x05\x04test")))
for i := 0; i < bench.N; i++ {
ach <- "test"
<-bch
}
axport.Close()
bxport.Close()
}