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