1 Star 0 Fork 63

jangocheng/carbon

forked from dromara/carbon 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
language_bench_test.go 888 Bytes
一键复制 编辑 原始数据 按行查看 历史
gouguoyin 提交于 2024-01-12 10:57 . v2.3.5
package carbon
import "testing"
func BenchmarkCarbon_SetLanguage(b *testing.B) {
lang := NewLanguage()
for n := 0; n < b.N; n++ {
SetLanguage(lang)
}
}
func BenchmarkCarbon_NewLanguage(b *testing.B) {
for n := 0; n < b.N; n++ {
NewLanguage()
}
}
func BenchmarkLanguage_SetLocale(b *testing.B) {
l := NewLanguage()
for n := 0; n < b.N; n++ {
l.SetLocale("zh-CN")
}
}
func BenchmarkLanguage_SetResources(b *testing.B) {
l := NewLanguage()
resources := map[string]string{
"seasons": "spring|summer|autumn|winter",
"year": "1 yr|%d yrs",
"month": "1 mo|%d mos",
"week": "%dw",
"day": "%dd",
"hour": "%dh",
"minute": "%dm",
"second": "%ds",
"now": "just now",
"ago": "%s ago",
"from_now": "in %s",
"before": "%s before",
"after": "%s after",
}
for n := 0; n < b.N; n++ {
l.SetResources(resources)
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/jangocheng/carbon.git
git@gitee.com:jangocheng/carbon.git
jangocheng
carbon
carbon
master

搜索帮助