Skip to content

Commit

Permalink
Add a large file for benchmark result.
Browse files Browse the repository at this point in the history
  • Loading branch information
huacnlee committed Jan 30, 2024
1 parent 3ffb0bb commit 29ac474
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,12 @@ Run `go test -bench=.` to benchmark.

```
pkg: github.com/longbridgeapp/autocorrect
BenchmarkFormat50-12 19671 60175 ns/op
BenchmarkFormat100-12 10000 119076 ns/op
BenchmarkFormat400-12 2847 424984 ns/op
Benchmark_halfwidth-12 289411 4150 ns/op
BenchmarkFormatHTML-12 1100 1097027 ns/op
BenchmarkFormat50-8 28234 40439 ns/op
BenchmarkFormat100-8 15157 79213 ns/op
BenchmarkFormat400-8 4172 287352 ns/op
Benchmark_halfwidth-8 526154 2248 ns/op
BenchmarkFormatHTML-8 1663 713339 ns/op
BenchmarkFormatHTML_large-8 18 64326771 ns/op
```

### Format
Expand All @@ -134,6 +135,7 @@ BenchmarkFormatHTML-12 1100 1097027 ns/op
| Total chars | Duration |
| ----------- | -------- |
| 2K | 1.09 ms |
| 400K | 63.36 ms |

## License

Expand Down
1 change: 1 addition & 0 deletions _fixtures/large.html

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions html_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,12 @@ func TestUnformatHTML(t *testing.T) {
assert.EqualHTML(t, "<p>Hello world this is english.</p><p><strong>2018至2019财年</strong>,印度电力部门总进口额为7100亿卢比(约合672亿人民币)其中2100亿卢比来自中国</p><p>占比29.6%,这意味着中国是印度电力设备的国外主要供应商。</p>", out)

}

func BenchmarkFormatHTML_large(b *testing.B) {
raw := readFile("large.html")

for i := 0; i < b.N; i++ {
// about 1.07ms/op
FormatHTML(raw)
}
}

0 comments on commit 29ac474

Please sign in to comment.