diff options
author | hmhealey <harrisonmhealey@gmail.com> | 2015-09-17 11:04:26 -0400 |
---|---|---|
committer | hmhealey <harrisonmhealey@gmail.com> | 2015-09-17 11:10:06 -0400 |
commit | 4005d8bfd09819280ffce4135f659060172e72a9 (patch) | |
tree | ae3f5cc29e0fa4d2a543e5cdbe471685981731fb /Godeps/_workspace/src/github.com/golang/freetype/freetype_test.go | |
parent | 047fec54ccc3b0d72bb6a425d06302ffa210553f (diff) | |
download | chat-4005d8bfd09819280ffce4135f659060172e72a9.tar.gz chat-4005d8bfd09819280ffce4135f659060172e72a9.tar.bz2 chat-4005d8bfd09819280ffce4135f659060172e72a9.zip |
Updated godep workspace and freetype library so that godep save and restore work again
Diffstat (limited to 'Godeps/_workspace/src/github.com/golang/freetype/freetype_test.go')
-rw-r--r-- | Godeps/_workspace/src/github.com/golang/freetype/freetype_test.go | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/github.com/golang/freetype/freetype_test.go b/Godeps/_workspace/src/github.com/golang/freetype/freetype_test.go new file mode 100644 index 000000000..348c411ab --- /dev/null +++ b/Godeps/_workspace/src/github.com/golang/freetype/freetype_test.go @@ -0,0 +1,59 @@ +// Copyright 2012 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 freetype + +import ( + "image" + "image/draw" + "io/ioutil" + "runtime" + "strings" + "testing" +) + +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 := ParseFont(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) + + c := NewContext() + c.SetDst(dst) + c.SetClip(dst.Bounds()) + c.SetSrc(image.Black) + c.SetFont(f) + + var ms runtime.MemStats + runtime.ReadMemStats(&ms) + mallocs := ms.Mallocs + + b.ResetTimer() + for i := 0; i < b.N; i++ { + for j, line := range lines { + _, err := c.DrawString(line, Pt(0, (j*16)%600)) + if err != nil { + b.Fatal(err) + } + } + } + b.StopTimer() + runtime.ReadMemStats(&ms) + mallocs = ms.Mallocs - mallocs + b.Logf("%d iterations, %d mallocs per iteration\n", b.N, int(mallocs)/b.N) +} |