Skip to content

Commit

Permalink
docs: add some simple benchmark for markdown (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bisstocuz authored Aug 21, 2023
1 parent 4980a81 commit c8f302a
Show file tree
Hide file tree
Showing 5 changed files with 3,939 additions and 1 deletion.
File renamed without changes.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ if err != nil {
fmt.Println(output)
// Output: H1 \nitalic bold code `not code link image strikethrough
```
#### Benchmark
```shell
goos: windows
goarch: amd64
pkg: github.com/huantt/plaintext-extractor/markdown
cpu: 11th Gen Intel(R) Core(TM) i5-1155G7 @ 2.50GHz
BenchmarkMarkdownExtractorMediumSize
BenchmarkMarkdownExtractorMediumSize-8 12194006 89.09 ns/op 16 B/op 1 allocs/op
BenchmarkMarkdownExtractorLargeSize
BenchmarkMarkdownExtractorLargeSize-8 12645927 88.25 ns/op 16 B/op 1 allocs/op
PASS
```

### Custom Markdown Tag
```go
Expand Down
26 changes: 25 additions & 1 deletion markdown/extractor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package markdown

import (
"fmt"
"github.com/stretchr/testify/assert"
"os"
"regexp"
"testing"

"github.com/stretchr/testify/assert"
)

func TestExtract(t *testing.T) {
Expand Down Expand Up @@ -54,3 +56,25 @@ func TestCustomTag(t *testing.T) {
assert.Equal(t, test.expected, *output)
}
}

func BenchmarkMarkdownExtractorMediumSize(b *testing.B) {
data, _ := os.ReadFile("testdata/markdown/go-validator.md")
input := string(data)

extractor := NewExtractor()
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, _ = extractor.PlainText(input)
}
}

func BenchmarkMarkdownExtractorLargeSize(b *testing.B) {
data, _ := os.ReadFile("testdata/markdown/awesome-go.md")
input := string(data)

extractor := NewExtractor()
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, _ = extractor.PlainText(input)
}
}
Loading

0 comments on commit c8f302a

Please sign in to comment.