Skip to content

Commit

Permalink
passthrough: Add a basic benchmark
Browse files Browse the repository at this point in the history
```bash
BenchmarkWithAndWithoutPassthrough/without_passthrough-10         	  250126	      4943 ns/op	   10448 B/op	      47 allocs/op
BenchmarkWithAndWithoutPassthrough/with_passthrough-10            	  240734	      4873 ns/op	   11128 B/op	      50 allocs/op
```
  • Loading branch information
bep authored Jan 24, 2024
1 parent 4a3408c commit 12f8bd8
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions passthrough/passthrough_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,3 +546,38 @@ $$a^*=x-b^*$$
c := qt.New(t)
c.Assert(actual, qt.Equals, expected)
}

func BenchmarkWithAndWithoutPassthrough(b *testing.B) {
const input = `
## Block
$$
a^*=x-b^*
$$
## Inline
Inline $a^*=x-b^*$ equation.`

b.Run("without passthrough", func(b *testing.B) {
md := goldmark.New()
b.ResetTimer()
for i := 0; i < b.N; i++ {
var buf bytes.Buffer
if err := md.Convert([]byte(input), &buf); err != nil {
b.Fatal(err)
}
}
})

b.Run("with passthrough", func(b *testing.B) {
md := buildTestParser()
b.ResetTimer()
for i := 0; i < b.N; i++ {
var buf bytes.Buffer
if err := md.Convert([]byte(input), &buf); err != nil {
b.Fatal(err)
}
}
})
}

0 comments on commit 12f8bd8

Please sign in to comment.