all repos — captcha @ 62d3514ca0a88e51dddd54230c9c4426a43408d3

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

Add store set/collect benchmark.
Dmitry Chestnykh dmitry@codingrobots.com
Thu, 28 Apr 2011 21:02:19 +0200
commit

62d3514ca0a88e51dddd54230c9c4426a43408d3

parent

d6bfb3fd16f213d34e00e2e546c922172873b076

1 files changed, 18 insertions(+), 0 deletions(-)

jump to
M store_test.gostore_test.go

@@ -57,3 +57,21 @@ if nc > 0 {

t.Errorf("= not collected %d out of %d captchas", nc, len(ids)) } } + + +func BenchmarkSetCollect(b *testing.B) { + b.StopTimer() + d := RandomDigits(10) + s := NewMemoryStore(9999, -1) + ids := make([]string, 1000) + for i := range ids { + ids[i] = uniuri.New() + } + b.StartTimer() + for i := 0; i < b.N; i++ { + for j := 0; j < 1000; j++ { + s.Set(ids[j], d) + } + s.(*memoryStore).collect() + } +}