mirror of
https://gitee.com/johng/gf.git
synced 2024-12-04 05:07:44 +08:00
92 lines
1.8 KiB
Go
92 lines
1.8 KiB
Go
// 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=".*"
|
|
|
|
package gset_test
|
|
|
|
import (
|
|
"testing"
|
|
"strconv"
|
|
"gitee.com/johng/gf/g/container/gset"
|
|
)
|
|
|
|
var ints = gset.NewIntSet()
|
|
var uints = gset.NewUintSet()
|
|
var itfs = gset.NewInterfaceSet()
|
|
var strs = gset.NewStringSet()
|
|
|
|
func BenchmarkIntSet_Add(b *testing.B) {
|
|
for i := 0; i < b.N; i++ {
|
|
ints.Add(i)
|
|
}
|
|
}
|
|
|
|
func BenchmarkIntSet_Contains(b *testing.B) {
|
|
for i := 0; i < b.N; i++ {
|
|
ints.Contains(i)
|
|
}
|
|
}
|
|
|
|
func BenchmarkIntSet_Remove(b *testing.B) {
|
|
for i := 0; i < b.N; i++ {
|
|
ints.Remove(i)
|
|
}
|
|
}
|
|
|
|
func BenchmarkUintSet_Add(b *testing.B) {
|
|
for i := 0; i < b.N; i++ {
|
|
uints.Add(uint(i))
|
|
}
|
|
}
|
|
|
|
func BenchmarkUintSet_Contains(b *testing.B) {
|
|
for i := 0; i < b.N; i++ {
|
|
uints.Contains(uint(i))
|
|
}
|
|
}
|
|
|
|
func BenchmarkUintSet_Remove(b *testing.B) {
|
|
for i := 0; i < b.N; i++ {
|
|
uints.Remove(uint(i))
|
|
}
|
|
}
|
|
|
|
func BenchmarkInterfaceSet_Add(b *testing.B) {
|
|
for i := 0; i < b.N; i++ {
|
|
itfs.Add(i)
|
|
}
|
|
}
|
|
|
|
func BenchmarkInterfaceSet_Contains(b *testing.B) {
|
|
for i := 0; i < b.N; i++ {
|
|
itfs.Contains(i)
|
|
}
|
|
}
|
|
|
|
func BenchmarkInterfaceSet_Remove(b *testing.B) {
|
|
for i := 0; i < b.N; i++ {
|
|
itfs.Remove(i)
|
|
}
|
|
}
|
|
|
|
func BenchmarkStringSet_Add(b *testing.B) {
|
|
for i := 0; i < b.N; i++ {
|
|
strs.Add(strconv.Itoa(i))
|
|
}
|
|
}
|
|
|
|
func BenchmarkStringSet_Contains(b *testing.B) {
|
|
for i := 0; i < b.N; i++ {
|
|
strs.Contains(strconv.Itoa(i))
|
|
}
|
|
}
|
|
|
|
func BenchmarkStringSet_Remove(b *testing.B) {
|
|
for i := 0; i < b.N; i++ {
|
|
strs.Remove(strconv.Itoa(i))
|
|
}
|
|
} |