What is Nostr?
mleku
npub1fjq…leku
2024-05-30 22:37:00
in reply to nevent1q…h909

mleku on Nostr: cpu: AMD Ryzen 5 PRO 4650G with Radeon Graphics BenchmarkBinaryEncoding ...

cpu: AMD Ryzen 5 PRO 4650G with Radeon Graphics
BenchmarkBinaryEncoding
BenchmarkBinaryEncoding/gob.Encode
BenchmarkBinaryEncoding/gob.Encode-12 6886 151743 ns/op
BenchmarkBinaryEncoding/binary.Marshal
BenchmarkBinaryEncoding/binary.Marshal-12 5544 204894 ns/op
BenchmarkBinaryEncoding/binary.MarshalBinary
BenchmarkBinaryEncoding/binary.MarshalBinary-12 5832 203333 ns/op

this is how the code should have looked to be fair

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()
}
}
})

and yes, i was right, it's almost 25% faster than your thing
Author Public Key
npub1fjqqy4a93z5zsjwsfxqhc2764kvykfdyttvldkkkdera8dr78vhsmmleku