github.com/gogf/gf@v1.16.9/internal/utils/utils_z_bench_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  package utils_test
     8  
     9  import (
    10  	"github.com/gogf/gf/internal/utils"
    11  	"regexp"
    12  	"testing"
    13  )
    14  
    15  var (
    16  	replaceCharReg, _ = regexp.Compile(`[\-\.\_\s]+`)
    17  )
    18  
    19  func Benchmark_RemoveSymbols(b *testing.B) {
    20  	for i := 0; i < b.N; i++ {
    21  		utils.RemoveSymbols(`-a-b._a c1!@#$%^&*()_+:";'.,'01`)
    22  	}
    23  }
    24  
    25  func Benchmark_RegularReplaceChars(b *testing.B) {
    26  	for i := 0; i < b.N; i++ {
    27  		replaceCharReg.ReplaceAllString(`-a-b._a c1!@#$%^&*()_+:";'.,'01`, "")
    28  	}
    29  }