| 1 |
package fastcache |
| 2 |
|
| 3 |
import ( |
| 4 |
"testing" |
| 5 |
) |
| 6 |
|
| 7 |
func BenchmarkSetBig(b *testing.B) { |
| 8 |
key := []byte("key12345") |
| 9 |
value := createValue(256*1024, 0) |
| 10 |
c := New(1024 * 1024) |
| 11 |
b.SetBytes(int64(len(value))) |
| 12 |
b.ReportAllocs() |
| 13 |
b.RunParallel(func(pb *testing.PB) { |
| 14 |
for pb.Next() { |
| 15 |
c.SetBig(key, value) |
| 16 |
} |
| 17 |
}) |
| 18 |
} |
| 19 |
|
| 20 |
func BenchmarkGetBig(b *testing.B) { |
| 21 |
key := []byte("key12345") |
| 22 |
value := createValue(265*1024, 0) |
| 23 |
c := New(1024 * 1024) |
| 24 |
c.SetBig(key, value) |
| 25 |
b.SetBytes(int64(len(value))) |
| 26 |
b.ReportAllocs() |
| 27 |
b.RunParallel(func(pb *testing.PB) { |
| 28 |
var buf []byte |
| 29 |
for pb.Next() { |
| 30 |
buf = c.GetBig(buf[:0], key) |
| 31 |
} |
| 32 |
}) |
| 33 |
} |