typeset/flow_test.go

40 lines
1.0 KiB
Go
Raw Permalink Normal View History

2024-09-19 19:05:18 -06:00
package typeset
import "testing"
import "golang.org/x/image/math/fixed"
import "golang.org/x/image/font/basicfont"
func BenchmarkFlowLipsumLeftTop (benchmark *testing.B) {
benchmarkFlow(benchmark, false, AlignStart, AlignStart)
}
func BenchmarkFlowLipsumWrapLeftTop (benchmark *testing.B) {
benchmarkFlow(benchmark, true, AlignStart, AlignStart)
}
func BenchmarkFlowLipsumCenterTop (benchmark *testing.B) {
benchmarkFlow(benchmark, false, AlignMiddle, AlignStart)
}
func BenchmarkFlowLipsumWrapCenterTop (benchmark *testing.B) {
benchmarkFlow(benchmark, true, AlignMiddle, AlignStart)
}
func BenchmarkFlowLipsumWrapJustifyTop (benchmark *testing.B) {
benchmarkFlow(benchmark, true, AlignEven, AlignStart)
}
func benchmarkFlow (benchmark *testing.B, wrap bool, xAlign, yAlign Align) {
_, tokens := parseString(lipsumLt)
2024-09-19 20:08:37 -06:00
measure(tokens, basicfont.Face7x13)
2024-09-19 19:05:18 -06:00
benchmark.ReportAllocs()
benchmark.ResetTimer()
for i := 0; i < benchmark.N; i ++ {
reflow (
tokens,
basicfont.Face7x13,
fixed.P(256, 256),
wrap, xAlign, yAlign)
}
}