github.com/wangyougui/gf/v2@v2.6.5/container/gvar/gvar_z_bench_ptr_test.go (about) 1 // Copyright GoFrame Author(https://goframe.org). 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/wangyougui/gf. 6 7 // go test *.go -bench=".*" -benchmem 8 9 package gvar 10 11 import "testing" 12 13 var varPtr = New(nil) 14 15 func Benchmark_Ptr_Set(b *testing.B) { 16 for i := 0; i < b.N; i++ { 17 varPtr.Set(i) 18 } 19 } 20 21 func Benchmark_Ptr_Val(b *testing.B) { 22 for i := 0; i < b.N; i++ { 23 varPtr.Val() 24 } 25 } 26 27 func Benchmark_Ptr_IsNil(b *testing.B) { 28 for i := 0; i < b.N; i++ { 29 varPtr.IsNil() 30 } 31 } 32 33 func Benchmark_Ptr_Bytes(b *testing.B) { 34 for i := 0; i < b.N; i++ { 35 varPtr.Bytes() 36 } 37 } 38 39 func Benchmark_Ptr_String(b *testing.B) { 40 for i := 0; i < b.N; i++ { 41 varPtr.String() 42 } 43 } 44 45 func Benchmark_Ptr_Bool(b *testing.B) { 46 for i := 0; i < b.N; i++ { 47 varPtr.Bool() 48 } 49 } 50 51 func Benchmark_Ptr_Int(b *testing.B) { 52 for i := 0; i < b.N; i++ { 53 varPtr.Int() 54 } 55 } 56 57 func Benchmark_Ptr_Int8(b *testing.B) { 58 for i := 0; i < b.N; i++ { 59 varPtr.Int8() 60 } 61 } 62 63 func Benchmark_Ptr_Int16(b *testing.B) { 64 for i := 0; i < b.N; i++ { 65 varPtr.Int16() 66 } 67 } 68 69 func Benchmark_Ptr_Int32(b *testing.B) { 70 for i := 0; i < b.N; i++ { 71 varPtr.Int32() 72 } 73 } 74 75 func Benchmark_Ptr_Int64(b *testing.B) { 76 for i := 0; i < b.N; i++ { 77 varPtr.Int64() 78 } 79 } 80 81 func Benchmark_Ptr_Uint(b *testing.B) { 82 for i := 0; i < b.N; i++ { 83 varPtr.Uint() 84 } 85 } 86 87 func Benchmark_Ptr_Uint8(b *testing.B) { 88 for i := 0; i < b.N; i++ { 89 varPtr.Uint8() 90 } 91 } 92 93 func Benchmark_Ptr_Uint16(b *testing.B) { 94 for i := 0; i < b.N; i++ { 95 varPtr.Uint16() 96 } 97 } 98 99 func Benchmark_Ptr_Uint32(b *testing.B) { 100 for i := 0; i < b.N; i++ { 101 varPtr.Uint32() 102 } 103 } 104 105 func Benchmark_Ptr_Uint64(b *testing.B) { 106 for i := 0; i < b.N; i++ { 107 varPtr.Uint64() 108 } 109 } 110 111 func Benchmark_Ptr_Float32(b *testing.B) { 112 for i := 0; i < b.N; i++ { 113 varPtr.Float32() 114 } 115 } 116 117 func Benchmark_Ptr_Float64(b *testing.B) { 118 for i := 0; i < b.N; i++ { 119 varPtr.Float64() 120 } 121 } 122 123 func Benchmark_Ptr_Ints(b *testing.B) { 124 for i := 0; i < b.N; i++ { 125 varPtr.Ints() 126 } 127 } 128 129 func Benchmark_Ptr_Strings(b *testing.B) { 130 for i := 0; i < b.N; i++ { 131 varPtr.Strings() 132 } 133 } 134 135 func Benchmark_Ptr_Floats(b *testing.B) { 136 for i := 0; i < b.N; i++ { 137 varPtr.Floats() 138 } 139 } 140 141 func Benchmark_Ptr_Interfaces(b *testing.B) { 142 for i := 0; i < b.N; i++ { 143 varPtr.Interfaces() 144 } 145 }