go-html/codegen/bench_test.go
Snider 7efd2ab93a test: add benchmarks, Unicode edge cases, and stress tests
Performance benchmarks across all major APIs:
- BenchmarkRender (depth 1/3/5/7 tree, full page)
- BenchmarkImprint (small/large pipeline)
- BenchmarkCompareVariants (2/3 variants)
- BenchmarkLayout (C, HCF, HLCRF, nested, many children)
- BenchmarkEach (10/100/1000 items)
- BenchmarkResponsive, BenchmarkStripTags
- Codegen: GenerateClass, TagToClassName, GenerateBundle, GenerateRegistration

Edge case tests:
- Unicode: emoji, RTL (Arabic/Hebrew), zero-width chars, mixed scripts
- Deep nesting: 10/20 levels, mixed slot types
- Large Each iterations: 1000/5000 items, nested Each
- Layout variant validation: invalid chars, lowercase, duplicates, empty
- Nil context handling for Render, Imprint, CompareVariants
- Switch no-match, Entitled nil context, empty tag El

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 05:33:15 +00:00

46 lines
808 B
Go

package codegen
import "testing"
func BenchmarkGenerateClass(b *testing.B) {
for b.Loop() {
GenerateClass("photo-grid", "C")
}
}
func BenchmarkTagToClassName(b *testing.B) {
for b.Loop() {
TagToClassName("my-super-widget-component")
}
}
func BenchmarkGenerateBundle_Small(b *testing.B) {
slots := map[string]string{
"H": "nav-bar",
"C": "main-content",
}
b.ResetTimer()
for b.Loop() {
GenerateBundle(slots)
}
}
func BenchmarkGenerateBundle_Full(b *testing.B) {
slots := map[string]string{
"H": "nav-bar",
"L": "side-panel",
"C": "main-content",
"R": "aside-widget",
"F": "page-footer",
}
b.ResetTimer()
for b.Loop() {
GenerateBundle(slots)
}
}
func BenchmarkGenerateRegistration(b *testing.B) {
for b.Loop() {
GenerateRegistration("photo-grid", "PhotoGrid")
}
}