~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to src/pkg/image/png/writer_test.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-08-20 14:06:23 UTC
  • mfrom: (14.1.23 saucy-proposed)
  • Revision ID: package-import@ubuntu.com-20130820140623-b414jfxi3m0qkmrq
Tags: 2:1.1.2-2ubuntu1
* Merge from Debian unstable (LP: #1211749, #1202027). Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - d/control,control.cross: Update Breaks/Replaces for Ubuntu
    versions to ensure smooth upgrades, regenerate control file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
101
101
        }
102
102
}
103
103
 
 
104
func BenchmarkEncodeGray(b *testing.B) {
 
105
        b.StopTimer()
 
106
        img := image.NewGray(image.Rect(0, 0, 640, 480))
 
107
        b.SetBytes(640 * 480 * 1)
 
108
        b.StartTimer()
 
109
        for i := 0; i < b.N; i++ {
 
110
                Encode(ioutil.Discard, img)
 
111
        }
 
112
}
 
113
 
 
114
func BenchmarkEncodeNRGBOpaque(b *testing.B) {
 
115
        b.StopTimer()
 
116
        img := image.NewNRGBA(image.Rect(0, 0, 640, 480))
 
117
        // Set all pixels to 0xFF alpha to force opaque mode.
 
118
        bo := img.Bounds()
 
119
        for y := bo.Min.Y; y < bo.Max.Y; y++ {
 
120
                for x := bo.Min.X; x < bo.Max.X; x++ {
 
121
                        img.Set(x, y, color.NRGBA{0, 0, 0, 255})
 
122
                }
 
123
        }
 
124
        if !img.Opaque() {
 
125
                b.Fatal("expected image to be opaque")
 
126
        }
 
127
        b.SetBytes(640 * 480 * 4)
 
128
        b.StartTimer()
 
129
        for i := 0; i < b.N; i++ {
 
130
                Encode(ioutil.Discard, img)
 
131
        }
 
132
}
 
133
 
 
134
func BenchmarkEncodeNRGBA(b *testing.B) {
 
135
        b.StopTimer()
 
136
        img := image.NewNRGBA(image.Rect(0, 0, 640, 480))
 
137
        if img.Opaque() {
 
138
                b.Fatal("expected image not to be opaque")
 
139
        }
 
140
        b.SetBytes(640 * 480 * 4)
 
141
        b.StartTimer()
 
142
        for i := 0; i < b.N; i++ {
 
143
                Encode(ioutil.Discard, img)
 
144
        }
 
145
}
 
146
 
104
147
func BenchmarkEncodePaletted(b *testing.B) {
105
148
        b.StopTimer()
106
149
        img := image.NewPaletted(image.Rect(0, 0, 640, 480), color.Palette{
138
181
        b.StopTimer()
139
182
        img := image.NewRGBA(image.Rect(0, 0, 640, 480))
140
183
        if img.Opaque() {
141
 
                b.Fatal("expected image to not be opaque")
 
184
                b.Fatal("expected image not to be opaque")
142
185
        }
143
186
        b.SetBytes(640 * 480 * 4)
144
187
        b.StartTimer()