vitess-gh/go/cache/perf_test.go

29 строки
505 B
Go
Исходник Обычный вид История

// Copyright 2012, Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
2012-02-25 11:30:03 +04:00
package cache
import (
"testing"
)
type MyValue []byte
2013-04-11 02:43:10 +04:00
func (mv MyValue) Size() int {
return cap(mv)
2012-02-25 11:30:03 +04:00
}
func BenchmarkGet(b *testing.B) {
cache := NewLRUCache(64 * 1024 * 1024)
value := make(MyValue, 1000)
cache.Set("stuff", value)
for i := 0; i < b.N; i++ {
val, ok := cache.Get("stuff")
if !ok {
panic("error")
}
_ = val
}
}