aboutsummaryrefslogtreecommitdiffhomepage
path: root/transform
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2023-10-29 17:50:55 +0100
committerBjørn Erik Pedersen <[email protected]>2023-10-29 17:50:55 +0100
commitb8fbd4a57818b60358a2473f48ef94a528ad58c5 (patch)
tree98dd84e836e5d8b5e001b20787f41e6fdabd235b /transform
parente2b2092ce6421dba4f3b4037ab0f3d29a2ababe2 (diff)
downloadhugo-b8fbd4a57818b60358a2473f48ef94a528ad58c5.tar.gz
hugo-b8fbd4a57818b60358a2473f48ef94a528ad58c5.zip
transform/livereloadinject: Add benchmark
Diffstat (limited to 'transform')
-rw-r--r--transform/livereloadinject/livereloadinject_test.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/transform/livereloadinject/livereloadinject_test.go b/transform/livereloadinject/livereloadinject_test.go
index d5cee79f8..cba2d3834 100644
--- a/transform/livereloadinject/livereloadinject_test.go
+++ b/transform/livereloadinject/livereloadinject_test.go
@@ -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)
+ }
+}