make simdjson great again.

now it is generally a little faster than the easyjson approach.

goos: linux
goarch: amd64
pkg: github.com/nbd-wtf/go-nostr
cpu: AMD Ryzen 3 3200G with Radeon Vega Graphics
BenchmarkParseMessage/stdlib-4         	      90	  15616341 ns/op
BenchmarkParseMessage/easyjson-4       	     110	  11306466 ns/op
BenchmarkParseMessage/simdjson-4       	     162	   7779856 ns/op
PASS
ok  	github.com/nbd-wtf/go-nostr	5.547s
This commit is contained in:
fiatjaf
2025-03-05 23:42:16 -03:00
parent de358e641c
commit 4fb6fcd9a2
6 changed files with 258 additions and 257 deletions

View File

@ -304,9 +304,10 @@ func TestParseMessageSIMD(t *testing.T) {
}
for _, testCase := range testCases {
smp := SIMDMessageParser{AuxIter: &simdjson.Iter{}}
t.Run(testCase.Name, func(t *testing.T) {
var pj *simdjson.ParsedJson
envelope, err := ParseMessageSIMD(testCase.Message, pj)
envelope, err := smp.ParseMessage(testCase.Message)
if testCase.ExpectedErrorSubstring == "" {
require.NoError(t, err)