audio_test.go 625 B

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