git.sr.ht/~pingoo/stdx@v0.0.0-20240218134121-094174641f6e/validate/converter_benchmark_test.go (about)

     1  package validate
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  func BenchmarkToBoolean(b *testing.B) {
     8  	b.ResetTimer()
     9  
    10  	for n := 0; n < b.N; n++ {
    11  		_, _ = ToBoolean("False    ")
    12  	}
    13  }
    14  
    15  func BenchmarkToInt(b *testing.B) {
    16  	b.ResetTimer()
    17  
    18  	for n := 0; n < b.N; n++ {
    19  		_, _ = ToInt("-22342342.2342")
    20  	}
    21  }
    22  
    23  func BenchmarkToFloat(b *testing.B) {
    24  	b.ResetTimer()
    25  
    26  	for n := 0; n < b.N; n++ {
    27  		_, _ = ToFloat("-22342342.2342")
    28  	}
    29  }
    30  
    31  func BenchmarkToString(b *testing.B) {
    32  	b.ResetTimer()
    33  
    34  	for n := 0; n < b.N; n++ {
    35  		ToString(randomArray(1000000))
    36  	}
    37  }
    38  
    39  func BenchmarkToJson(b *testing.B) {
    40  	b.ResetTimer()
    41  
    42  	for n := 0; n < b.N; n++ {
    43  		_, _ = ToJSON(randomArray(1000000))
    44  	}
    45  }