github.com/zhongdalu/gf@v1.0.0/g/os/gtime/gtime_z_bench_test.go (about) 1 // Copyright 2017 gf Author(https://github.com/zhongdalu/gf). 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/zhongdalu/gf. 6 7 package gtime_test 8 9 import ( 10 "testing" 11 12 "github.com/zhongdalu/gf/g/os/gtime" 13 ) 14 15 func Benchmark_Second(b *testing.B) { 16 for i := 0; i < b.N; i++ { 17 gtime.Second() 18 } 19 } 20 21 func Benchmark_Millisecond(b *testing.B) { 22 for i := 0; i < b.N; i++ { 23 gtime.Millisecond() 24 } 25 } 26 27 func Benchmark_Microsecond(b *testing.B) { 28 for i := 0; i < b.N; i++ { 29 gtime.Microsecond() 30 } 31 } 32 33 func Benchmark_Nanosecond(b *testing.B) { 34 for i := 0; i < b.N; i++ { 35 gtime.Nanosecond() 36 } 37 } 38 39 func Benchmark_StrToTime(b *testing.B) { 40 for i := 0; i < b.N; i++ { 41 gtime.StrToTime("2018-02-09T20:46:17.897Z") 42 } 43 } 44 45 func Benchmark_ParseTimeFromContent(b *testing.B) { 46 for i := 0; i < b.N; i++ { 47 gtime.ParseTimeFromContent("2018-02-09T20:46:17.897Z") 48 } 49 } 50 51 func Benchmark_NewFromTimeStamp(b *testing.B) { 52 for i := 0; i < b.N; i++ { 53 gtime.NewFromTimeStamp(1542674930) 54 } 55 } 56 57 func Benchmark_Date(b *testing.B) { 58 for i := 0; i < b.N; i++ { 59 gtime.Date() 60 } 61 } 62 63 func Benchmark_Datetime(b *testing.B) { 64 for i := 0; i < b.N; i++ { 65 gtime.Datetime() 66 } 67 } 68 69 func Benchmark_SetTimeZone(b *testing.B) { 70 for i := 0; i < b.N; i++ { 71 gtime.SetTimeZone("Asia/Shanghai") 72 } 73 }