What is Nostr?
mleku
npub1fjq…leku
2024-05-30 22:46:18

mleku on Nostr: i've been working with #golang intensively since 2018 i didn't become a Go maxi for ...

i've been working with #golang intensively since 2018

i didn't become a Go maxi for nothing, and i know what i'm talking about

you all who think i just hate your functional or OOP or rust because i'm a cranky kitty i didn't get this way from nothing, i have had a lot of experience with all the things, had OOM kills on builds and waited hours for compilations for applications that take under a minute on a totally fresh Go install



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