2021-01-17 21:46:25 +08:00
|
|
|
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
|
2020-11-08 00:06:05 +08:00
|
|
|
//
|
|
|
|
// This Source Code Form is subject to the terms of the MIT License.
|
|
|
|
// If a copy of the MIT was not distributed with this file,
|
|
|
|
// You can obtain one at https://github.com/gogf/gf.
|
|
|
|
|
|
|
|
package utils_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gogf/gf/internal/utils"
|
|
|
|
"regexp"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
replaceCharReg, _ = regexp.Compile(`[\-\.\_\s]+`)
|
|
|
|
)
|
|
|
|
|
|
|
|
func Benchmark_RemoveSymbols(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
utils.RemoveSymbols(`-a-b._a c1!@#$%^&*()_+:";'.,'01`)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func Benchmark_RegularReplaceChars(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
replaceCharReg.ReplaceAllString(`-a-b._a c1!@#$%^&*()_+:";'.,'01`, "")
|
|
|
|
}
|
|
|
|
}
|