github.com/zhongdalu/gf@v1.0.0/g/container/gvar/gvar_z_bench_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=".*" -benchmem 8 9 package gvar 10 11 import "testing" 12 13 var vn = New(nil) 14 15 func Benchmark_Set(b *testing.B) { 16 for i := 0; i < b.N; i++ { 17 vn.Set(i) 18 } 19 } 20 21 func Benchmark_Val(b *testing.B) { 22 for i := 0; i < b.N; i++ { 23 vn.Val() 24 } 25 } 26 27 func Benchmark_IsNil(b *testing.B) { 28 for i := 0; i < b.N; i++ { 29 vn.IsNil() 30 } 31 } 32 33 func Benchmark_Bytes(b *testing.B) { 34 for i := 0; i < b.N; i++ { 35 vn.Bytes() 36 } 37 } 38 39 func Benchmark_String(b *testing.B) { 40 for i := 0; i < b.N; i++ { 41 vn.String() 42 } 43 } 44 45 func Benchmark_Bool(b *testing.B) { 46 for i := 0; i < b.N; i++ { 47 vn.Bool() 48 } 49 } 50 51 func Benchmark_Int(b *testing.B) { 52 for i := 0; i < b.N; i++ { 53 vn.Int() 54 } 55 } 56 57 func Benchmark_Int8(b *testing.B) { 58 for i := 0; i < b.N; i++ { 59 vn.Int8() 60 } 61 } 62 63 func Benchmark_Int16(b *testing.B) { 64 for i := 0; i < b.N; i++ { 65 vn.Int16() 66 } 67 } 68 69 func Benchmark_Int32(b *testing.B) { 70 for i := 0; i < b.N; i++ { 71 vn.Int32() 72 } 73 } 74 75 func Benchmark_Int64(b *testing.B) { 76 for i := 0; i < b.N; i++ { 77 vn.Int64() 78 } 79 } 80 81 func Benchmark_Uint(b *testing.B) { 82 for i := 0; i < b.N; i++ { 83 vn.Uint() 84 } 85 } 86 87 func Benchmark_Uint8(b *testing.B) { 88 for i := 0; i < b.N; i++ { 89 vn.Uint8() 90 } 91 } 92 93 func Benchmark_Uint16(b *testing.B) { 94 for i := 0; i < b.N; i++ { 95 vn.Uint16() 96 } 97 } 98 99 func Benchmark_Uint32(b *testing.B) { 100 for i := 0; i < b.N; i++ { 101 vn.Uint32() 102 } 103 } 104 105 func Benchmark_Uint64(b *testing.B) { 106 for i := 0; i < b.N; i++ { 107 vn.Uint64() 108 } 109 } 110 111 func Benchmark_Float32(b *testing.B) { 112 for i := 0; i < b.N; i++ { 113 vn.Float32() 114 } 115 } 116 117 func Benchmark_Float64(b *testing.B) { 118 for i := 0; i < b.N; i++ { 119 vn.Float64() 120 } 121 } 122 123 func Benchmark_Ints(b *testing.B) { 124 for i := 0; i < b.N; i++ { 125 vn.Ints() 126 } 127 } 128 129 func Benchmark_Strings(b *testing.B) { 130 for i := 0; i < b.N; i++ { 131 vn.Strings() 132 } 133 } 134 135 func Benchmark_Floats(b *testing.B) { 136 for i := 0; i < b.N; i++ { 137 vn.Floats() 138 } 139 } 140 141 func Benchmark_Interfaces(b *testing.B) { 142 for i := 0; i < b.N; i++ { 143 vn.Interfaces() 144 } 145 }