| 12345678910111213141516171819202122232425262728293031 |
- package captcha
- import (
- "os"
- "testing"
- )
- type devNull struct{}
- func (devNull) Write(b []byte) (int, os.Error) {
- return len(b), nil
- }
- func BenchmarkNewImage(b *testing.B) {
- b.StopTimer()
- d := RandomDigits(DefaultLen)
- b.StartTimer()
- for i := 0; i < b.N; i++ {
- NewImage(d, StdWidth, StdHeight)
- }
- }
- func BenchmarkImageWriteTo(b *testing.B) {
- b.StopTimer()
- d := RandomDigits(DefaultLen)
- b.StartTimer()
- for i := 0; i < b.N; i++ {
- img := NewImage(d, StdWidth, StdHeight)
- img.WriteTo(devNull{}) //TODO(dchest): use ioutil.Discard when its available
- }
- }
|