codes.Code.String() does a switch.
(b *testing.B)
| 102 | |
| 103 | // codes.Code.String() does a switch. |
| 104 | func BenchmarkCodeStringSwitch(b *testing.B) { |
| 105 | for i := 0; i < b.N; i++ { |
| 106 | c := codes.Code(uint32(i % 17)) |
| 107 | _ = c.String() |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | // Testing all codes (0<=c<=16) and also one overflow (17). |
| 112 | func BenchmarkCodeStringStringerWithOverflow(b *testing.B) { |