MCPcopy
hub / github.com/gorilla/websocket / BenchmarkMaskBytes

Function BenchmarkMaskBytes

mask_test.go:47–72  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

45}
46
47func BenchmarkMaskBytes(b *testing.B) {
48 for _, size := range []int{2, 4, 8, 16, 32, 512, 1024} {
49 b.Run(fmt.Sprintf("size-%d", size), func(b *testing.B) {
50 for _, align := range []int{wordSize / 2} {
51 b.Run(fmt.Sprintf("align-%d", align), func(b *testing.B) {
52 for _, fn := range []struct {
53 name string
54 fn func(key [4]byte, pos int, b []byte) int
55 }{
56 {"byte", maskBytesByByte},
57 {"word", maskBytes},
58 } {
59 b.Run(fn.name, func(b *testing.B) {
60 key := newMaskKey()
61 data := make([]byte, size+align)[align:]
62 for i := 0; i < b.N; i++ {
63 fn.fn(key, 0, data)
64 }
65 b.SetBytes(int64(len(data)))
66 })
67 }
68 })
69 }
70 })
71 }
72}

Callers

nothing calls this directly

Calls 1

newMaskKeyFunction · 0.85

Tested by

no test coverage detected