mirror of
https://gitee.com/johng/gf.git
synced 2024-12-03 04:37:49 +08:00
62 lines
999 B
Go
62 lines
999 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()
|
|
)
|
|
|
|
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()
|
|
}
|
|
})
|
|
}
|