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 b.StartTimer()
16 for i := 0; i < b.N; i++ {
17 NewAudio(d, "")
18 }
19}
20
21func BenchmarkAudioWriteTo(b *testing.B) {
22 b.StopTimer()
23 d := RandomDigits(DefaultLen)
24 b.StartTimer()
25 for i := 0; i < b.N; i++ {
26 a := NewAudio(d, "")
27 n, _ := a.WriteTo(ioutil.Discard)
28 b.SetBytes(n)
29 }
30}