github.com/gogf/gf/v2@v2.7.4/os/gtime/gtime_z_bench_test.go (about)

     1  // Copyright GoFrame Author(https://goframe.org). 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/gogf/gf.
     6  
     7  package gtime_test
     8  
     9  import (
    10  	"testing"
    11  	"time"
    12  
    13  	"github.com/gogf/gf/v2/os/gtime"
    14  )
    15  
    16  func Benchmark_Timestamp(b *testing.B) {
    17  	for i := 0; i < b.N; i++ {
    18  		gtime.Timestamp()
    19  	}
    20  }
    21  
    22  func Benchmark_TimestampMilli(b *testing.B) {
    23  	for i := 0; i < b.N; i++ {
    24  		gtime.TimestampMilli()
    25  	}
    26  }
    27  
    28  func Benchmark_TimestampMicro(b *testing.B) {
    29  	for i := 0; i < b.N; i++ {
    30  		gtime.TimestampMicro()
    31  	}
    32  }
    33  
    34  func Benchmark_TimestampNano(b *testing.B) {
    35  	for i := 0; i < b.N; i++ {
    36  		gtime.TimestampNano()
    37  	}
    38  }
    39  
    40  func Benchmark_StrToTime(b *testing.B) {
    41  	for i := 0; i < b.N; i++ {
    42  		gtime.StrToTime("2018-02-09T20:46:17.897Z")
    43  	}
    44  }
    45  
    46  func Benchmark_StrToTime_Format(b *testing.B) {
    47  	for i := 0; i < b.N; i++ {
    48  		gtime.StrToTime("2018-02-09 20:46:17.897", "Y-m-d H:i:su")
    49  	}
    50  }
    51  
    52  func Benchmark_StrToTime_Layout(b *testing.B) {
    53  	for i := 0; i < b.N; i++ {
    54  		gtime.StrToTimeLayout("2018-02-09T20:46:17.897Z", time.RFC3339)
    55  	}
    56  }
    57  
    58  func Benchmark_ParseTimeFromContent(b *testing.B) {
    59  	for i := 0; i < b.N; i++ {
    60  		gtime.ParseTimeFromContent("2018-02-09T20:46:17.897Z")
    61  	}
    62  }
    63  
    64  func Benchmark_NewFromTimeStamp(b *testing.B) {
    65  	for i := 0; i < b.N; i++ {
    66  		gtime.NewFromTimeStamp(1542674930)
    67  	}
    68  }
    69  
    70  func Benchmark_Date(b *testing.B) {
    71  	for i := 0; i < b.N; i++ {
    72  		gtime.Date()
    73  	}
    74  }
    75  
    76  func Benchmark_Datetime(b *testing.B) {
    77  	for i := 0; i < b.N; i++ {
    78  		gtime.Datetime()
    79  	}
    80  }