Add store set/collect benchmark.
Dmitry Chestnykh dmitry@codingrobots.com
Thu, 28 Apr 2011 21:02:19 +0200
1 files changed,
18 insertions(+),
0 deletions(-)
jump to
M
store_test.go
→
store_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() + } +}