/
githubmirror
/
GoFrame
Обзор
Документация
Войти
/
githubmirror
/
GoFrame
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
container/gmap/gmap_z_bench_maps_test.go
82 строки
1 KB
houseme
add golangci feature to guarantee codes quality (#2229)
01 ноя 2022, 15:12
Не верифицирован
01 ноя 2022, 15:12
1793bf0
Код
Авторство
О чём код?
// 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 gm file, // You can obtain one at https://github.com/gogf/gf. // go test *.go -bench=".*" -benchmem package gmap_test import ( "testing" "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/util/gutil" ) var hashMap = gmap.New(true) var listMap = gmap.NewListMap(true) var treeMap = gmap.NewTreeMap(gutil.ComparatorInt, true) func Benchmark_HashMap_Set(b *testing.B) { b.RunParallel(func(pb *testing.PB) { i := 0 for pb.Next() { hashMap.Set(i, i) i++ } }) } func Benchmark_ListMap_Set(b *testing.B) { b.RunParallel(func(pb *testing.PB) { i := 0 for pb.Next() { listMap.Set(i, i) i++ } }) } func Benchmark_TreeMap_Set(b *testing.B) { b.RunParallel(func(pb *testing.PB) { i := 0 for pb.Next() { treeMap.Set(i, i) i++ } }) } func Benchmark_HashMap_Get(b *testing.B) { b.RunParallel(func(pb *testing.PB) { i := 0 for pb.Next() { hashMap.Get(i) i++ } }) } func Benchmark_ListMap_Get(b *testing.B) { b.RunParallel(func(pb *testing.PB) { i := 0 for pb.Next() { listMap.Get(i) i++ } }) } func Benchmark_TreeMap_Get(b *testing.B) { b.RunParallel(func(pb *testing.PB) { i := 0 for pb.Next() { treeMap.Get(i) i++ } }) }