From 92ba5904c1645e6572f5ff1b9d0e0ec629e1afb9 Mon Sep 17 00:00:00 2001 From: Markus Wüstenberg Date: Thu, 29 Oct 2020 15:40:14 +0100 Subject: Remove fmt.Sprintf call in attribute Render (#38) Just concatenating the strings is much faster. Before: ``` make benchmark go test -bench=. goos: darwin goarch: amd64 pkg: github.com/maragudk/gomponents BenchmarkAttr/boolean_attributes-8 8194791 139 ns/op BenchmarkAttr/name-value_attributes-8 5143292 229 ns/op PASS ok github.com/maragudk/gomponents 2.841s ``` After: ``` make benchmark go test -bench=. goos: darwin goarch: amd64 pkg: github.com/maragudk/gomponents BenchmarkAttr/boolean_attributes-8 16755404 67.0 ns/op BenchmarkAttr/name-value_attributes-8 10208625 116 ns/op PASS ok github.com/maragudk/gomponents 2.702s ```--- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index dc8bb1f..c453239 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,7 @@ -.PHONY: cover lint test +.PHONY: benchmark cover lint test + +benchmark: + go test -bench=. cover: go tool cover -html=cover.out -- cgit 1.4.1