2018-02-12 15:33:19 +08:00
|
|
|
// Copyright 2017 gf Author(https://gitee.com/johng/gf). All Rights Reserved.
|
|
|
|
|
//
|
|
|
|
|
// This Source Code Form is subject to the terms of the MIT License.
|
|
|
|
|
// If a copy of the MIT was not distributed with this file,
|
|
|
|
|
// You can obtain one at https://gitee.com/johng/gf.
|
|
|
|
|
|
|
|
|
|
// go test *.go -bench=".*"
|
|
|
|
|
|
2018-05-28 13:58:59 +08:00
|
|
|
package gcache
|
2018-02-12 15:33:19 +08:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
"strconv"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func BenchmarkSet(b *testing.B) {
|
|
|
|
|
for i := 0; i < b.N; i++ {
|
2018-05-28 13:58:59 +08:00
|
|
|
Set(strconv.Itoa(i), strconv.Itoa(i), 0)
|
2018-02-12 15:33:19 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func BenchmarkGet(b *testing.B) {
|
|
|
|
|
for i := 0; i < b.N; i++ {
|
2018-05-28 13:58:59 +08:00
|
|
|
Get(strconv.Itoa(i))
|
2018-02-12 15:33:19 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func BenchmarkRemove(b *testing.B) {
|
|
|
|
|
for i := 0; i < b.N; i++ {
|
2018-05-28 13:58:59 +08:00
|
|
|
Remove(strconv.Itoa(i))
|
2018-02-12 15:33:19 +08:00
|
|
|
}
|
|
|
|
|
}
|