(b *testing.B)
| 991 | } |
| 992 | |
| 993 | func BenchmarkCacheGet(b *testing.B) { |
| 994 | b.ReportAllocs() |
| 995 | b.StopTimer() |
| 996 | cache := NewCache(256 * 1024 * 1024) |
| 997 | var key [8]byte |
| 998 | buf := make([]byte, 64) |
| 999 | for i := 0; i < b.N; i++ { |
| 1000 | binary.LittleEndian.PutUint64(key[:], uint64(i)) |
| 1001 | cache.Set(key[:], buf, 0) |
| 1002 | } |
| 1003 | b.StartTimer() |
| 1004 | for i := 0; i < b.N; i++ { |
| 1005 | binary.LittleEndian.PutUint64(key[:], uint64(i)) |
| 1006 | cache.Get(key[:]) |
| 1007 | } |
| 1008 | } |
| 1009 | |
| 1010 | func BenchmarkCacheGetFn(b *testing.B) { |
| 1011 | b.ReportAllocs() |