github.com/wangyougui/gf/v2@v2.6.5/util/gconv/gconv_z_bench_float_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 gconv
    10  
    11  import (
    12  	"testing"
    13  )
    14  
    15  var valueFloat = float64(1.23456789)
    16  
    17  func Benchmark_Float_To_String(b *testing.B) {
    18  	for i := 0; i < b.N; i++ {
    19  		String(valueFloat)
    20  	}
    21  }
    22  
    23  func Benchmark_Float_To_Int(b *testing.B) {
    24  	for i := 0; i < b.N; i++ {
    25  		Int(valueFloat)
    26  	}
    27  }
    28  
    29  func Benchmark_Float_To_Int8(b *testing.B) {
    30  	for i := 0; i < b.N; i++ {
    31  		Int8(valueFloat)
    32  	}
    33  }
    34  
    35  func Benchmark_Float_To_Int16(b *testing.B) {
    36  	for i := 0; i < b.N; i++ {
    37  		Int16(valueFloat)
    38  	}
    39  }
    40  
    41  func Benchmark_Float_To_Int32(b *testing.B) {
    42  	for i := 0; i < b.N; i++ {
    43  		Int32(valueFloat)
    44  	}
    45  }
    46  
    47  func Benchmark_Float_To_Int64(b *testing.B) {
    48  	for i := 0; i < b.N; i++ {
    49  		Int(valueFloat)
    50  	}
    51  }
    52  
    53  func Benchmark_Float_To_Uint(b *testing.B) {
    54  	for i := 0; i < b.N; i++ {
    55  		Uint(valueFloat)
    56  	}
    57  }
    58  
    59  func Benchmark_Float_To_Uint8(b *testing.B) {
    60  	for i := 0; i < b.N; i++ {
    61  		Uint8(valueFloat)
    62  	}
    63  }
    64  
    65  func Benchmark_Float_To_Uint16(b *testing.B) {
    66  	for i := 0; i < b.N; i++ {
    67  		Uint16(valueFloat)
    68  	}
    69  }
    70  
    71  func Benchmark_Float_To_Uint32(b *testing.B) {
    72  	for i := 0; i < b.N; i++ {
    73  		Uint32(valueFloat)
    74  	}
    75  }
    76  
    77  func Benchmark_Float_To_Uint64(b *testing.B) {
    78  	for i := 0; i < b.N; i++ {
    79  		Uint64(valueFloat)
    80  	}
    81  }
    82  
    83  func Benchmark_Float_To_Float32(b *testing.B) {
    84  	for i := 0; i < b.N; i++ {
    85  		Float32(valueFloat)
    86  	}
    87  }
    88  
    89  func Benchmark_Float_To_Float64(b *testing.B) {
    90  	for i := 0; i < b.N; i++ {
    91  		Float64(valueFloat)
    92  	}
    93  }
    94  
    95  func Benchmark_Float_To_Time(b *testing.B) {
    96  	for i := 0; i < b.N; i++ {
    97  		Time(valueFloat)
    98  	}
    99  }
   100  
   101  func Benchmark_Float_To_TimeDuration(b *testing.B) {
   102  	for i := 0; i < b.N; i++ {
   103  		Duration(valueFloat)
   104  	}
   105  }
   106  
   107  func Benchmark_Float_To_Bytes(b *testing.B) {
   108  	for i := 0; i < b.N; i++ {
   109  		Bytes(valueFloat)
   110  	}
   111  }
   112  
   113  func Benchmark_Float_To_Strings(b *testing.B) {
   114  	for i := 0; i < b.N; i++ {
   115  		Strings(valueFloat)
   116  	}
   117  }
   118  
   119  func Benchmark_Float_To_Ints(b *testing.B) {
   120  	for i := 0; i < b.N; i++ {
   121  		Ints(valueFloat)
   122  	}
   123  }
   124  
   125  func Benchmark_Float_To_Floats(b *testing.B) {
   126  	for i := 0; i < b.N; i++ {
   127  		Floats(valueFloat)
   128  	}
   129  }
   130  
   131  func Benchmark_Float_To_Interfaces(b *testing.B) {
   132  	for i := 0; i < b.N; i++ {
   133  		Interfaces(valueFloat)
   134  	}
   135  }