diff --git a/naive/naive_test.go b/naive/naive_test.go index 1b35ef9..b0a9cd3 100644 --- a/naive/naive_test.go +++ b/naive/naive_test.go @@ -56,3 +56,53 @@ func BenchmarkBind9(b *testing.B) { } }) } + +func BenchmarkSeq5(b *testing.B) { + type P = gigaparsec.Parser[byte, byte] + type Seq5T = func(P, P, P, P, P, func(byte, byte, byte, byte, byte) byte) P + + zero := gigaparsec.Return[byte, byte](0) + + f := func(a, b, c, d, e byte) byte { + return a + b + c + d + e + } + p := func(seq5 Seq5T) P { + return seq5(zero, zero, zero, zero, zero, f) + } + input := gigaparsec.SliceReaderAt[byte]{0} + b.Run("gigaparsec.Seq5", func(b *testing.B) { + for range b.N { + gigaparsec.Run(p(gigaparsec.Seq5), input) + } + }) + b.Run("naive.Seq5", func(b *testing.B) { + for range b.N { + gigaparsec.Run(p(naive.Seq5), input) + } + }) +} + +func BenchmarkSeq9(b *testing.B) { + type P = gigaparsec.Parser[byte, byte] + type Seq9T = func(P, P, P, P, P, P, P, P, P, func(byte, byte, byte, byte, byte, byte, byte, byte, byte) byte) P + + zero := gigaparsec.Return[byte, byte](0) + + f := func(a, b, c, d, e, f, g, h, i byte) byte { + return a + b + c + d + e + f + g + h + i + } + p := func(seq9 Seq9T) P { + return seq9(zero, zero, zero, zero, zero, zero, zero, zero, zero, f) + } + input := gigaparsec.SliceReaderAt[byte]{0} + b.Run("gigaparsec.Seq9", func(b *testing.B) { + for range b.N { + gigaparsec.Run(p(gigaparsec.Seq9), input) + } + }) + b.Run("naive.Seq9", func(b *testing.B) { + for range b.N { + gigaparsec.Run(p(naive.Seq9), input) + } + }) +}