gf/container/glist/glist_z_bench_test.go
2019-08-26 23:35:44 +08:00

62 lines
1003 B
Go

// Copyright 2018 gf Author(https://github.com/gogf/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://github.com/gogf/gf.
// go test *.go -bench=".*" -benchmem
package glist
import (
"testing"
)
var (
l = New(true)
)
func Benchmark_PushBack(b *testing.B) {
b.RunParallel(func(pb *testing.PB) {
i := 0
for pb.Next() {
l.PushBack(i)
i++
}
})
}
func Benchmark_PushFront(b *testing.B) {
b.RunParallel(func(pb *testing.PB) {
i := 0
for pb.Next() {
l.PushFront(i)
i++
}
})
}
func Benchmark_Len(b *testing.B) {
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
l.Len()
}
})
}
func Benchmark_PopFront(b *testing.B) {
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
l.PopFront()
}
})
}
func Benchmark_PopBack(b *testing.B) {
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
l.PopBack()
}
})
}