/
githubmirror
/
GoFrame
Обзор
Документация
Войти
/
githubmirror
/
GoFrame
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
net/ghttp/ghttp_z_bench_test.go
41 строка
899 B
John Guo
copyright comment update
17 янв 2021, 16:46
17 янв 2021, 16:46
093034a
Код
Авторство
О чём код?
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. // // 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 ghttp_test import ( "strings" "testing" ) func Benchmark_TrimRightCharWithStrings(b *testing.B) { for i := 0; i < b.N; i++ { path := "//////////" path = strings.TrimRight(path, "/") } } func Benchmark_TrimRightCharWithSlice1(b *testing.B) { for i := 0; i < b.N; i++ { path := "//////////" for len(path) > 0 && path[len(path)-1] == '/' { path = path[:len(path)-1] } } } func Benchmark_TrimRightCharWithSlice2(b *testing.B) { for i := 0; i < b.N; i++ { path := "//////////" for { if length := len(path); length > 0 && path[length-1] == '/' { path = path[:length-1] } else { break } } } }