go test -race -bench Benchmark_local_cache -run =^$ -cpu 1,2,4,8
PASS
Benchmark_local_cache 1000000 2310 ns/op
Benchmark_local_cache-2 1000000 2828 ns/op
Benchmark_local_cache-4 500000 3848 ns/op
Benchmark_local_cache-8 500000 3542 ns/op
func Benchmark_local_cache(B *testing.B) {
lc := newLocalCache(10, 1)
id := "id"
for i := 0; i < B.N; i++ {
lc.Get(id)
}
}
网友评论