carbon/getter_bench_test.go

508 lines
7.3 KiB
Go
Raw Normal View History

2023-12-28 11:27:27 +08:00
package carbon
import "testing"
func BenchmarkCarbon_DaysInYear(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.DaysInYear()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.DaysInYear()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_DaysInMonth(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.DaysInMonth()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.DaysInMonth()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_MonthOfYear(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.MonthOfYear()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.MonthOfYear()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_DayOfYear(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.DayOfYear()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.DayOfYear()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_DayOfMonth(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.DayOfMonth()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.DayOfMonth()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_DayOfWeek(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.DayOfWeek()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.DayOfWeek()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_WeekOfYear(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.WeekOfYear()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.WeekOfYear()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_WeekOfMonth(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.WeekOfMonth()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.WeekOfMonth()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_DateTime(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.DateTime()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.DateTime()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_DateTimeMilli(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.DateTimeMilli()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.DateTimeMilli()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_DateTimeMicro(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.DateTimeMilli()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.DateTimeMilli()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_DateTimeNano(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.DateTimeNano()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.DateTimeNano()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_Date(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.Date()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.Date()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_DateMilli(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.DateMilli()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.DateMilli()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_DateMicro(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.DateMicro()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.DateMicro()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_DateNano(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.DateNano()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.DateNano()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_Time(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.Time()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.Time()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_TimeMilli(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.TimeMilli()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.TimeMilli()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_TimeMicro(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.TimeMicro()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.TimeMicro()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_TimeNano(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.TimeNano()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.TimeNano()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_Century(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.Century()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.Century()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_Decade(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.Decade()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.Decade()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_Year(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.Year()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.Year()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_Quarter(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.Quarter()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.Quarter()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_Month(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.Month()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.Month()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_Week(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.Week()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.Week()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_Day(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.Day()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.Day()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_Hour(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.Hour()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.Hour()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_Minute(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.Minute()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.Minute()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_Second(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.Second()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.Second()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_Millisecond(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.Millisecond()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.Millisecond()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_Microsecond(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.Microsecond()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.Microsecond()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_Nanosecond(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.Nanosecond()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.Nanosecond()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_Timestamp(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.Timestamp()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.Timestamp()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_TimestampMilli(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.TimestampMilli()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.TimestampMilli()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_TimestampMicro(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.TimestampMicro()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.TimestampMicro()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_TimestampNano(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.TimestampNano()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.TimestampNano()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_Location(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.Location()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.Location()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_Timezone(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.Timezone()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.Timezone()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_Offset(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.Offset()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.Offset()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_Locale(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.Locale()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.Locale()
}
2023-12-28 11:27:27 +08:00
}
func BenchmarkCarbon_Age(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.Age()
}
2024-01-12 10:57:10 +08:00
c := NewCarbon()
for n := 0; n < b.N; n++ {
c.Age()
}
2023-12-28 11:27:27 +08:00
}