github.com/zhongdalu/gf@v1.0.0/g/container/gring/gring_test.go (about) 1 // Copyright 2018 gf Author(https://github.com/zhongdalu/gf). All Rights Reserved. 2 // 3 // This Source Code Form is subject to the terms of the MIT License. 4 // If a copy of the MIT was not distributed with this file, 5 // You can obtain one at https://github.com/zhongdalu/gf. 6 7 // go test *.go -bench=".*" 8 9 package gring 10 11 import ( 12 "testing" 13 ) 14 15 var length = 10000 16 var r1 = New(length) 17 18 func BenchmarkRing_Put(b *testing.B) { 19 for i := 0; i < b.N; i++ { 20 r1.Put(i) 21 } 22 } 23 24 func BenchmarkRing_Next(b *testing.B) { 25 for i := 0; i < b.N; i++ { 26 r1.Next() 27 } 28 } 29 30 func BenchmarkRing_Set(b *testing.B) { 31 for i := 0; i < b.N; i++ { 32 r1.Set(i) 33 } 34 } 35 36 func BenchmarkRing_Len(b *testing.B) { 37 for i := 0; i < b.N; i++ { 38 r1.Len() 39 } 40 } 41 42 func BenchmarkRing_Cap(b *testing.B) { 43 for i := 0; i < b.N; i++ { 44 r1.Cap() 45 } 46 }