all repos — captcha @ 1f906795e89e40dd5aa06cbe18548c1ad686cc2d

Go package captcha implements generation and verification of image and audio CAPTCHAs.

audio_test.go (view raw)

 1package captcha
 2
 3import (
 4	"io/ioutil"
 5	"testing"
 6)
 7
 8func BenchmarkNewAudio(b *testing.B) {
 9	b.StopTimer()
10	d := RandomDigits(DefaultLen)
11	b.StartTimer()
12	for i := 0; i < b.N; i++ {
13		NewAudio(d, "")
14	}
15}
16
17func BenchmarkAudioWriteTo(b *testing.B) {
18	b.StopTimer()
19	d := RandomDigits(DefaultLen)
20	b.StartTimer()
21	for i := 0; i < b.N; i++ {
22		a := NewAudio(d, "")
23		n, _ := a.WriteTo(ioutil.Discard)
24		b.SetBytes(n)
25	}
26}