mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
transform/livereloadinject: Add benchmark
This commit is contained in:
parent
e2b2092ce6
commit
b8fbd4a578
1 changed files with 24 additions and 0 deletions
|
@ -15,6 +15,7 @@ package livereloadinject
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"net/url"
|
||||
"strings"
|
||||
"testing"
|
||||
|
@ -70,3 +71,26 @@ func TestLiveReloadInject(t *testing.T) {
|
|||
c.Assert(apply("<h1>No match</h1>"), qt.Equals, "<h1>No match</h1>"+expectBase+warnScript)
|
||||
})
|
||||
}
|
||||
|
||||
func BenchmarkLiveReloadInject(b *testing.B) {
|
||||
s := `
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
`
|
||||
in := strings.NewReader(s)
|
||||
lrurl, err := url.Parse("http://localhost:1234/subpath")
|
||||
if err != nil {
|
||||
b.Fatalf("Parsing test URL failed")
|
||||
}
|
||||
tr := transform.New(New(*lrurl))
|
||||
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
in.Seek(0, 0)
|
||||
tr.Apply(io.Discard, in)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue