(b *testing.B)
| 100 | } |
| 101 | |
| 102 | func BenchmarkStringsCut(b *testing.B) { |
| 103 | testStrings := []struct { |
| 104 | name string |
| 105 | s string |
| 106 | }{ |
| 107 | {"short-no-match", "tenant-a"}, |
| 108 | {"short-match", "tenant:k6"}, |
| 109 | {"medium-no-match", "tenant-abcdefghijklmnop"}, |
| 110 | {"medium-match-end", "tenant-abcdefghijklmnop:k6"}, |
| 111 | {"long-no-match", "tenant-abcdefghijklmnopqrstuvwxyz0123456789"}, |
| 112 | {"long-match-end", "tenant-abcdefghijklmnopqrstuvwxyz0123456789:k6"}, |
| 113 | } |
| 114 | |
| 115 | for _, ts := range testStrings { |
| 116 | b.Run("strings.Cut/"+ts.name, func(b *testing.B) { |
| 117 | s := ts.s |
| 118 | for i := 0; i < b.N; i++ { |
| 119 | _, _, _ = strings.Cut(s, ":") |
| 120 | } |
| 121 | }) |
| 122 | b.Run("stringsCut/"+ts.name, func(b *testing.B) { |
| 123 | s := ts.s |
| 124 | for i := 0; i < b.N; i++ { |
| 125 | _, _, _ = stringsCut(s, ':') |
| 126 | } |
| 127 | }) |
| 128 | } |
| 129 | } |
nothing calls this directly
no test coverage detected