diff --git a/flow_test.go b/flow_test.go new file mode 100644 index 0000000..3cfbd0a --- /dev/null +++ b/flow_test.go @@ -0,0 +1,38 @@ +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) + } +}