diff options
author | Markus Wüstenberg | 2025-03-05 12:00:11 +0100 |
---|---|---|
committer | GitHub | 2025-03-05 12:00:11 +0100 |
commit | 1e222b67fe5d47aba02827c6746c49a11ba3c743 (patch) | |
tree | 3c421b52fb3e1963776120d3e330509675521e08 /html/elements_test.go | |
parent | ea676e9a323c7c29b272265a3e19e6f65af397d1 (diff) | |
download | gomponents-1e222b67fe5d47aba02827c6746c49a11ba3c743.tar.lz gomponents-1e222b67fe5d47aba02827c6746c49a11ba3c743.tar.zst gomponents-1e222b67fe5d47aba02827c6746c49a11ba3c743.zip |
Benchmark large document and run in CI (#246)
Fixes #229
Diffstat (limited to 'html/elements_test.go')
-rw-r--r-- | html/elements_test.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/html/elements_test.go b/html/elements_test.go index 5fe6268..7670af5 100644 --- a/html/elements_test.go +++ b/html/elements_test.go @@ -3,6 +3,7 @@ package html_test import ( "errors" "fmt" + "strings" "testing" g "maragu.dev/gomponents" @@ -164,3 +165,22 @@ func TestSimpleVoidKindElements(t *testing.T) { }) } } + +func BenchmarkLargeHTMLDocument(b *testing.B) { + b.ReportAllocs() + + for i := 0; i < b.N; i++ { + elements := make([]g.Node, 0, 10000) + + for i := 0; i < 5000; i++ { + elements = append(elements, + Div(Class("foo")), + Span(Class("bar")), + ) + } + doc := Div(elements...) + + var sb strings.Builder + _ = doc.Render(&sb) + } +} |