audio_test.go 411 B

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