mleku @mleku - 6mo
so, it took all morning, but i changed one of those stupid string fields to bytes now, the ID cpu: AMD Ryzen 5 PRO 4650G with Radeon Graphics BenchmarkBinaryEncoding/event2.MarshalJSON-12 14 73695929 ns/op BenchmarkBinaryEncoding/event2.EventToBinary-12 157 7280781 ns/op BenchmarkBinaryEncoding/easyjson.Marshal-12 64 19049795 ns/op BenchmarkBinaryEncoding/gob.Encode-12 18 62296062 ns/op BenchmarkBinaryEncoding/binary.Marshal-12 10 110174020 ns/op BenchmarkBinaryDecoding/event2.BinaryToEvent-12 100 13698489 ns/op BenchmarkBinaryDecoding/easyjson.Unmarshal-12 56 19677698 ns/op BenchmarkBinaryDecoding/gob.Decode-12 5 226144867 ns/op BenchmarkBinaryDecoding/binary.Unmarshal-12 122 9011042 ns/op BenchmarkBinaryDecoding/binary.UnmarshalBinary-12 277 4849297 ns/op BenchmarkBinaryDecoding/easyjson.Unmarshal+sig-12 1 1624027475 ns/op BenchmarkBinaryDecoding/binary.Unmarshal+sig-12 1 1596453002 ns/op just one of the fields, and from 139 to 157 - makes sense because it's not decoding hex anymore i'm surprised the decode didn't get faster, since it now literally only makes a new slice header (subslicing) small result for a lot of work but the pubkey and signature are still to come nostr:npub180cvv07tjdrrgpa0j7j7tmnyl2yr6yr7l8j4s3evf6u64th6gkwsyjh6w6 btw the UnmarshalBinary function you wrote is extremely fast, but the reason why its counterpart MarshalBinary isn't in there is because it can't deal with events over 64kb in size, otherwise i'd re-enable it
yes, it's not printing errors but the speed of that is because it's actually skipping a shit-ton of things i'm gonna just remove it
cpu: AMD Ryzen 5 PRO 4650G with Radeon Graphics BenchmarkBinaryEncoding/event2.MarshalJSON-12 15 74245789 ns/op BenchmarkBinaryEncoding/event2.EventToBinary-12 162 7429203 ns/op BenchmarkBinaryEncoding/easyjson.Marshal-12 60 21221235 ns/op BenchmarkBinaryEncoding/gob.Encode-12 18 62426577 ns/op BenchmarkBinaryEncoding/binary.Marshal-12 9 112783137 ns/op BenchmarkBinaryDecoding/event2.UnmarshalJSON-12 14 90464147 ns/op BenchmarkBinaryDecoding/event2.BinaryToEvent-12 100 12832888 ns/op BenchmarkBinaryDecoding/easyjson.Unmarshal-12 57 23280946 ns/op BenchmarkBinaryDecoding/gob.Decode-12 5 226555916 ns/op BenchmarkBinaryDecoding/binary.Unmarshal-12 128 8563056 ns/op the output from https://mleku.dev/nostrbench
now with the pubkey encoding as binary... not as dramatic an improvement it seems oh well, anyway, it's done now, both id and pubkey fields now do not need any hex encode/decode so that's still a good thing last is the signature... this will be another 5-10 ops more i figure, then i'm gonna get out the profiler goos: linux goarch: amd64 pkg: mleku.net/nostrbench cpu: AMD Ryzen 5 PRO 4650G with Radeon Graphics BenchmarkBinaryEncoding/event2.MarshalJSON-12 14 72883244 ns/op BenchmarkBinaryEncoding/event2.EventToBinary-12 166 7090886 ns/op BenchmarkBinaryEncoding/easyjson.Marshal-12 67 18620409 ns/op BenchmarkBinaryEncoding/gob.Encode-12 19 62998941 ns/op BenchmarkBinaryEncoding/binary.Marshal-12 10 110464204 ns/op BenchmarkBinaryDecoding/event2.UnmarshalJSON-12 13 87762713 ns/op BenchmarkBinaryDecoding/event2.BinaryToEvent-12 100 12388974 ns/op BenchmarkBinaryDecoding/easyjson.Unmarshal-12 57 23463646 ns/op BenchmarkBinaryDecoding/gob.Decode-12 5 226411371 ns/op BenchmarkBinaryDecoding/binary.Unmarshal-12 123 8851251 ns/op #devstr #benchmark #nostr