gf/os/gtime/gtime_z_bench_test.go
2021-01-03 23:37:45 +08:00

87 lines
1.7 KiB
Go

// 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 gtime_test
import (
"testing"
"time"
"github.com/gogf/gf/os/gtime"
)
func Benchmark_Timestamp(b *testing.B) {
for i := 0; i < b.N; i++ {
gtime.Timestamp()
}
}
func Benchmark_TimestampMilli(b *testing.B) {
for i := 0; i < b.N; i++ {
gtime.TimestampMilli()
}
}
func Benchmark_TimestampMicro(b *testing.B) {
for i := 0; i < b.N; i++ {
gtime.TimestampMicro()
}
}
func Benchmark_TimestampNano(b *testing.B) {
for i := 0; i < b.N; i++ {
gtime.TimestampNano()
}
}
func Benchmark_StrToTime(b *testing.B) {
for i := 0; i < b.N; i++ {
gtime.StrToTime("2018-02-09T20:46:17.897Z")
}
}
func Benchmark_StrToTime_Format(b *testing.B) {
for i := 0; i < b.N; i++ {
gtime.StrToTime("2018-02-09 20:46:17.897", "Y-m-d H:i:su")
}
}
func Benchmark_StrToTime_Layout(b *testing.B) {
for i := 0; i < b.N; i++ {
gtime.StrToTimeLayout("2018-02-09T20:46:17.897Z", time.RFC3339)
}
}
func Benchmark_ParseTimeFromContent(b *testing.B) {
for i := 0; i < b.N; i++ {
gtime.ParseTimeFromContent("2018-02-09T20:46:17.897Z")
}
}
func Benchmark_NewFromTimeStamp(b *testing.B) {
for i := 0; i < b.N; i++ {
gtime.NewFromTimeStamp(1542674930)
}
}
func Benchmark_Date(b *testing.B) {
for i := 0; i < b.N; i++ {
gtime.Date()
}
}
func Benchmark_Datetime(b *testing.B) {
for i := 0; i < b.N; i++ {
gtime.Datetime()
}
}
func Benchmark_SetTimeZone(b *testing.B) {
for i := 0; i < b.N; i++ {
gtime.SetTimeZone("Asia/Shanghai")
}
}