-
Notifications
You must be signed in to change notification settings - Fork 25
/
libasciidoc_bench_test.go
37 lines (32 loc) · 1.14 KB
/
libasciidoc_bench_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package libasciidoc_test
import (
"strings"
"testing"
"github.com/bytesparadise/libasciidoc"
"github.com/bytesparadise/libasciidoc/pkg/configuration"
// pkgprofile "github.com/pkg/profile"
"github.com/felixge/fgtrace"
log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
)
func BenchmarkRealDocumentProcessing(b *testing.B) {
// defer pkgprofile.Start(pkgprofile.MemProfile).Stop()
defer fgtrace.Config{Dst: fgtrace.File("./tmp/fgtrace.json")}.Trace().Stop() //nolint:errcheck
log.SetLevel(log.ErrorLevel)
b.Run("demo.adoc", processDocument("./test/compat/demo.adoc"))
b.Run("vertx-examples.adoc", processDocument("./test/bench/vertx-examples.adoc"))
b.Run("mocking.adoc", processDocument("./test/bench/mocking.adoc"))
}
func processDocument(filename string) func(b *testing.B) {
return func(b *testing.B) {
for i := 0; i < b.N; i++ {
out := &strings.Builder{}
_, err := libasciidoc.ConvertFile(out,
configuration.NewConfiguration(
configuration.WithFilename(filename),
configuration.WithCSS([]string{"path/to/style.css"}),
configuration.WithHeaderFooter(true)))
require.NoError(b, err)
}
}
}