/
githubmirror
/
GoFrame
Обзор
Документация
Войти
/
githubmirror
/
GoFrame
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
os/gcache/gcache_z_bench_test.go
81 строка
1 KB
John Guo
version 2
11 окт 2021, 16:41
11 окт 2021, 16:41
1bc0635
Код
Авторство
О чём код?
// Copyright GoFrame Author(https://goframe.org). 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://github.com/gogf/gf. // go test *.go -bench=".*" -benchmem package gcache_test import ( "context" "testing" "github.com/gogf/gf/v2/os/gcache" ) var ( localCache = gcache.New() localCacheLru = gcache.New(10000) ) func Benchmark_CacheSet(b *testing.B) { b.RunParallel(func(pb *testing.PB) { i := 0 for pb.Next() { localCache.Set(ctx, i, i, 0) i++ } }) } func Benchmark_CacheGet(b *testing.B) { b.RunParallel(func(pb *testing.PB) { i := 0 for pb.Next() { localCache.Get(ctx, i) i++ } }) } func Benchmark_CacheRemove(b *testing.B) { b.RunParallel(func(pb *testing.PB) { i := 0 for pb.Next() { localCache.Remove(ctx, i) i++ } }) } func Benchmark_CacheLruSet(b *testing.B) { b.RunParallel(func(pb *testing.PB) { i := 0 for pb.Next() { localCacheLru.Set(ctx, i, i, 0) i++ } }) } func Benchmark_CacheLruGet(b *testing.B) { b.RunParallel(func(pb *testing.PB) { i := 0 for pb.Next() { localCacheLru.Get(ctx, i) i++ } }) } func Benchmark_CacheLruRemove(b *testing.B) { b.RunParallel(func(pb *testing.PB) { i := 0 for pb.Next() { localCacheLru.Remove(context.TODO(), i) i++ } }) }