audio_test.go 581 B

123456789101112131415161718192021222324252627282930
  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. package captcha
  5. import (
  6. "io/ioutil"
  7. "testing"
  8. )
  9. func BenchmarkNewAudio(b *testing.B) {
  10. b.StopTimer()
  11. d := RandomDigits(DefaultLen)
  12. b.StartTimer()
  13. for i := 0; i < b.N; i++ {
  14. NewAudio(d, "")
  15. }
  16. }
  17. func 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. }