i put it in another reply
all i did was move the create codec step to outside the loop
b.Run("gob.Encode", func(b *testing.B) {
var buf bytes.Buffer
enc := gob.NewEncoder(&buf)
for i := 0; i < b.N; i++ {
for _, evt := range events {
enc.Encode(evt)
// _ = buf.Bytes()
}
}
})