diff options
author | =Corey Hulen <corey@hulen.com> | 2015-09-17 09:21:56 -0700 |
---|---|---|
committer | =Corey Hulen <corey@hulen.com> | 2015-09-17 09:21:56 -0700 |
commit | 9b5198c69c01ff11b0977282b61cf2222ef2f2b1 (patch) | |
tree | a5179226ff013f082a6629dbf888454c53611383 /Godeps/_workspace/src/github.com/golang/freetype/truetype/face_test.go | |
parent | 51c3445e694e68fdecd809f17fbaa64751e5931c (diff) | |
parent | 3edd8dbdf65e0b7be422a46328cb85482aa78f69 (diff) | |
download | chat-9b5198c69c01ff11b0977282b61cf2222ef2f2b1.tar.gz chat-9b5198c69c01ff11b0977282b61cf2222ef2f2b1.tar.bz2 chat-9b5198c69c01ff11b0977282b61cf2222ef2f2b1.zip |
Merge branch 'master' into PLT-92
Diffstat (limited to 'Godeps/_workspace/src/github.com/golang/freetype/truetype/face_test.go')
-rw-r--r-- | Godeps/_workspace/src/github.com/golang/freetype/truetype/face_test.go | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/github.com/golang/freetype/truetype/face_test.go b/Godeps/_workspace/src/github.com/golang/freetype/truetype/face_test.go new file mode 100644 index 000000000..856581dff --- /dev/null +++ b/Godeps/_workspace/src/github.com/golang/freetype/truetype/face_test.go @@ -0,0 +1,48 @@ +// Copyright 2015 The Freetype-Go Authors. All rights reserved. +// Use of this source code is governed by your choice of either the +// FreeType License or the GNU General Public License version 2 (or +// any later version), both of which can be found in the LICENSE file. + +package truetype + +import ( + "image" + "image/draw" + "io/ioutil" + "strings" + "testing" + + "golang.org/x/image/font" + "golang.org/x/image/math/fixed" +) + +func BenchmarkDrawString(b *testing.B) { + data, err := ioutil.ReadFile("../licenses/gpl.txt") + if err != nil { + b.Fatal(err) + } + lines := strings.Split(string(data), "\n") + data, err = ioutil.ReadFile("../testdata/luxisr.ttf") + if err != nil { + b.Fatal(err) + } + f, err := Parse(data) + if err != nil { + b.Fatal(err) + } + dst := image.NewRGBA(image.Rect(0, 0, 800, 600)) + draw.Draw(dst, dst.Bounds(), image.White, image.ZP, draw.Src) + d := &font.Drawer{ + Dst: dst, + Src: image.Black, + Face: NewFace(f, nil), + } + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + for j, line := range lines { + d.Dot = fixed.P(0, (j*16)%600) + d.DrawString(line) + } + } +} |