github.com/gogf/gf/v2@v2.7.4/util/gconv/gconv_z_bench_int_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/gogf/gf. 6 7 // go test *.go -bench=".*" -benchmem 8 9 package gconv 10 11 import ( 12 "testing" 13 ) 14 15 var valueInt = 123456789 16 17 func Benchmark_Int_To_String(b *testing.B) { 18 for i := 0; i < b.N; i++ { 19 String(valueInt) 20 } 21 } 22 23 func Benchmark_Int_To_Int(b *testing.B) { 24 for i := 0; i < b.N; i++ { 25 Int(valueInt) 26 } 27 } 28 29 func Benchmark_Int_To_Int8(b *testing.B) { 30 for i := 0; i < b.N; i++ { 31 Int8(valueInt) 32 } 33 } 34 35 func Benchmark_Int_To_Int16(b *testing.B) { 36 for i := 0; i < b.N; i++ { 37 Int16(valueInt) 38 } 39 } 40 41 func Benchmark_Int_To_Int32(b *testing.B) { 42 for i := 0; i < b.N; i++ { 43 Int32(valueInt) 44 } 45 } 46 47 func Benchmark_Int_To_Int64(b *testing.B) { 48 for i := 0; i < b.N; i++ { 49 Int(valueInt) 50 } 51 } 52 53 func Benchmark_Int_To_Uint(b *testing.B) { 54 for i := 0; i < b.N; i++ { 55 Uint(valueInt) 56 } 57 } 58 59 func Benchmark_Int_To_Uint8(b *testing.B) { 60 for i := 0; i < b.N; i++ { 61 Uint8(valueInt) 62 } 63 } 64 65 func Benchmark_Int_To_Uint16(b *testing.B) { 66 for i := 0; i < b.N; i++ { 67 Uint16(valueInt) 68 } 69 } 70 71 func Benchmark_Int_To_Uint32(b *testing.B) { 72 for i := 0; i < b.N; i++ { 73 Uint32(valueInt) 74 } 75 } 76 77 func Benchmark_Int_To_Uint64(b *testing.B) { 78 for i := 0; i < b.N; i++ { 79 Uint64(valueInt) 80 } 81 } 82 83 func Benchmark_Int_To_Float32(b *testing.B) { 84 for i := 0; i < b.N; i++ { 85 Float32(valueInt) 86 } 87 } 88 89 func Benchmark_Int_To_Float64(b *testing.B) { 90 for i := 0; i < b.N; i++ { 91 Float64(valueInt) 92 } 93 } 94 95 func Benchmark_Int_To_Time(b *testing.B) { 96 for i := 0; i < b.N; i++ { 97 Time(valueInt) 98 } 99 } 100 101 func Benchmark_Int_To_TimeDuration(b *testing.B) { 102 for i := 0; i < b.N; i++ { 103 Duration(valueInt) 104 } 105 } 106 107 func Benchmark_Int_To_Bytes(b *testing.B) { 108 for i := 0; i < b.N; i++ { 109 Bytes(valueInt) 110 } 111 } 112 113 func Benchmark_Int_To_Strings(b *testing.B) { 114 for i := 0; i < b.N; i++ { 115 Strings(valueInt) 116 } 117 } 118 119 func Benchmark_Int_To_Ints(b *testing.B) { 120 for i := 0; i < b.N; i++ { 121 Ints(valueInt) 122 } 123 } 124 125 func Benchmark_Int_To_Floats(b *testing.B) { 126 for i := 0; i < b.N; i++ { 127 Floats(valueInt) 128 } 129 } 130 131 func Benchmark_Int_To_Interfaces(b *testing.B) { 132 for i := 0; i < b.N; i++ { 133 Interfaces(valueInt) 134 } 135 }