github.com/cellofellow/gopkg@v0.0.0-20140722061823-eec0544a62ad/image/big/bench_test.go (about) 1 // Copyright 2014 <chaishushan{AT}gmail.com>. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package big 6 7 import ( 8 "image" 9 "image/color" 10 "runtime" 11 "testing" 12 ) 13 14 func init() { 15 runtime.GOMAXPROCS(runtime.NumCPU()) 16 } 17 18 func BenchmarkImage_ReadRect(b *testing.B) { 19 m := image.NewRGBA(image.Rect(0, 0, 1000, 2000)) 20 bigImg := NewImage(m.Bounds(), image.Pt(128, 128), color.RGBAModel) 21 b.ResetTimer() 22 for i := 0; i < b.N; i++ { 23 bigImg.ReadRect(-1, m.Bounds(), m) 24 } 25 } 26 27 func BenchmarkImage_WriteRect(b *testing.B) { 28 m := image.NewRGBA(image.Rect(0, 0, 1000, 2000)) 29 bigImg := NewImage(m.Bounds(), image.Pt(128, 128), color.RGBAModel) 30 b.ResetTimer() 31 for i := 0; i < b.N; i++ { 32 bigImg.WriteRect(-1, m.Bounds(), m) 33 } 34 }