typeset/flow_test.go

39 lines
1016 B
Go
Raw 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)
benchmark.ReportAllocs()
benchmark.ResetTimer()
for i := 0; i < benchmark.N; i ++ {
reflow (
tokens,
basicfont.Face7x13,
fixed.P(256, 256),
wrap, xAlign, yAlign)
}
}