all repos — captcha @ master

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

audio_test.go (view raw)

 1// Copyright 2011 Dmitry Chestnykh. All rights reserved.
 2// Use of this source code is governed by a MIT-style
 3// license that can be found in the LICENSE file.
 4
 5package captcha
 6
 7import (
 8	"io/ioutil"
 9	"testing"
10)
11
12func BenchmarkNewAudio(b *testing.B) {
13	b.StopTimer()
14	d := RandomDigits(DefaultLen)
15	id := randomId()
16	b.StartTimer()
17	for i := 0; i < b.N; i++ {
18		NewAudio(id, d, "")
19	}
20}
21
22func BenchmarkAudioWriteTo(b *testing.B) {
23	b.StopTimer()
24	d := RandomDigits(DefaultLen)
25	id := randomId()
26	b.StartTimer()
27	for i := 0; i < b.N; i++ {
28		a := NewAudio(id, d, "")
29		n, _ := a.WriteTo(ioutil.Discard)
30		b.SetBytes(n)
31	}
32}