mirror of
https://gitee.com/dromara/carbon.git
synced 2024-11-29 18:57:37 +08:00
添加性能测试文件
This commit is contained in:
parent
a2e8bea696
commit
4a30a86d5d
145
boundary_bench_test.go
Executable file
145
boundary_bench_test.go
Executable file
@ -0,0 +1,145 @@
|
||||
package carbon
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func BenchmarkCarbon_StartOfCentury(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.StartOfCentury()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_EndOfCentury(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.EndOfCentury()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_StartOfDecade(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.StartOfDecade()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_EndOfDecade(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.EndOfDecade()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_StartOfYear(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.StartOfYear()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_EndOfYear(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.EndOfYear()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_StartOfQuarter(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.StartOfQuarter()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_EndOfQuarter(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.EndOfQuarter()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_StartOfMonth(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.StartOfMonth()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_EndOfMonth(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.EndOfMonth()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_StartOfWeek(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.StartOfWeek()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_EndOfWeek(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.EndOfWeek()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_StartOfDay(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.StartOfDay()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_EndOfDay(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.EndOfDay()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_StartOfHour(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.StartOfHour()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_EndOfHour(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.EndOfHour()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_StartOfMinute(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.StartOfMinute()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_EndOfMinute(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.EndOfMinute()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_StartOfSecond(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.StartOfSecond()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_EndOfSecond(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.EndOfSecond()
|
||||
}
|
||||
}
|
296
calendar.lunar_bench_test.go
Executable file
296
calendar.lunar_bench_test.go
Executable file
@ -0,0 +1,296 @@
|
||||
package carbon
|
||||
|
||||
import "testing"
|
||||
|
||||
func BenchmarkCarbon_Lunar(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
Now().Lunar()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_Animal(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.Animal()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_Festival(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.Festival()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_DateTime(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.DateTime()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_Date(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.Date()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_Time(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.Time()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_Year(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.Year()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_Month(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.Month()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_LeapMonth(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.LeapMonth()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_Day(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.Day()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_ToYearString(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.ToYearString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_ToMonthString(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.ToMonthString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_ToDayString(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.ToDayString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_ToDateString(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.ToDateString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_String(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.String()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_IsLeapYear(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.IsLeapYear()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_IsLeapMonth(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.IsLeapMonth()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_IsRatYear(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.IsRatYear()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_IsOxYear(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.IsOxYear()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_IsTigerYear(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.IsTigerYear()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_IsRabbitYear(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.IsRabbitYear()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_IsDragonYear(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.IsDragonYear()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_IsSnakeYear(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.IsSnakeYear()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_IsHorseYear(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.IsHorseYear()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_IsGoatYear(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.IsGoatYear()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_IsMonkeyYear(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.IsMonkeyYear()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_IsRoosterYear(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.IsRoosterYear()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_IsDogYear(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.IsDogYear()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_IsPigYear(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.IsPigYear()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_DoubleHour(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.DoubleHour()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_IsFirstDoubleHour(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.IsFirstDoubleHour()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_IsSecondDoubleHour(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.IsSecondDoubleHour()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_IsThirdDoubleHour(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.IsThirdDoubleHour()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_IsFourthDoubleHour(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.IsFourthDoubleHour()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_IsFifthDoubleHour(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.IsFifthDoubleHour()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_IsSixthDoubleHour(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.IsSixthDoubleHour()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_IsSeventhDoubleHour(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.IsSeventhDoubleHour()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_IsEighthDoubleHour(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.IsEighthDoubleHour()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_IsNinthDoubleHour(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.IsNinthDoubleHour()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_IsTenthDoubleHour(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.IsTenthDoubleHour()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_IsEleventhDoubleHour(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.IsEleventhDoubleHour()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLunar_IsTwelfthDoubleHour(b *testing.B) {
|
||||
l := Now().Lunar()
|
||||
for n := 0; n < b.N; n++ {
|
||||
l.IsTwelfthDoubleHour()
|
||||
}
|
||||
}
|
374
comparer_bench_test.go
Executable file
374
comparer_bench_test.go
Executable file
@ -0,0 +1,374 @@
|
||||
package carbon
|
||||
|
||||
import "testing"
|
||||
|
||||
func BenchmarkCarbon_IsDST(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsDST()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsZero(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsZero()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsValid(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsZero()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsInvalid(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsInvalid()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsNow(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsNow()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsFuture(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsFuture()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsPast(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsPast()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsLeapYear(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsLeapYear()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsLongYear(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsLongYear()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsJanuary(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsJanuary()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsFebruary(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsFebruary()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsMarch(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsMarch()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsApril(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsApril()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsMay(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsMay()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsJune(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsJune()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsJuly(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsJuly()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsAugust(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsAugust()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsSeptember(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsSeptember()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsOctober(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsOctober()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsNovember(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsNovember()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsDecember(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsDecember()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsMonday(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsMonday()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsTuesday(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsTuesday()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsWednesday(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsWednesday()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsThursday(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsThursday()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsFriday(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsFriday()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsSaturday(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsSaturday()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsSunday(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsSunday()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsWeekday(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsWeekday()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsWeekend(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsWeekend()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsYesterday(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsYesterday()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsToday(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsToday()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsTomorrow(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsTomorrow()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsSameCentury(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsSameCentury(Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsSameDecade(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsSameDecade(Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsSameYear(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsSameYear(Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsSameQuarter(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsSameQuarter(Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsSameMonth(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsSameMonth(Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsSameDay(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsSameDay(Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsSameHour(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsSameHour(Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsSameMinute(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsSameMinute(Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsSameSecond(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsSameSecond(Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Compare(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Compare(">", Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Gt(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Gt(Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Lt(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Lt(Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Eq(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Eq(Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Ne(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Ne(Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Gte(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Gte(Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Lte(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Lte(Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Between(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Between(Tomorrow(), Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_BetweenIncludedStart(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.BetweenIncludedStart(Tomorrow(), Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_BetweenIncludedEnd(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.BetweenIncludedEnd(Tomorrow(), Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_BetweenIncludedBoth(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.BetweenIncludedBoth(Tomorrow(), Yesterday())
|
||||
}
|
||||
}
|
94
constellation_bench_test.go
Executable file
94
constellation_bench_test.go
Executable file
@ -0,0 +1,94 @@
|
||||
package carbon
|
||||
|
||||
import "testing"
|
||||
|
||||
func BenchmarkCarbon_Constellation(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Constellation()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsAries(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsAries()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsTaurus(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsTaurus()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsGemini(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsGemini()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsCancer(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsCancer()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsLeo(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsLeo()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsVirgo(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsVirgo()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsLibra(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsLibra()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsScorpio(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsScorpio()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsSagittarius(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsSagittarius()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsCapricorn(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsCapricorn()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsAquarius(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsAquarius()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsPisces(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsPisces()
|
||||
}
|
||||
}
|
108
creator_bench_test.go
Executable file
108
creator_bench_test.go
Executable file
@ -0,0 +1,108 @@
|
||||
package carbon
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func BenchmarkCarbon_CreateFromStdTime(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
CreateFromStdTime(time.Now())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_CreateFromTimestamp(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
CreateFromTimestamp(1649735755)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_CreateFromTimestampMilli(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
CreateFromTimestampMilli(1649735755981)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_CreateFromTimestampMicro(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
CreateFromTimestampMicro(1649735755981566)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_CreateFromTimestampNano(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
CreateFromTimestampNano(1649735755981566000)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_CreateFromDateTime(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
CreateFromDateTime(2020, 8, 5, 13, 14, 15)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_CreateFromDateTimeMilli(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
CreateFromDateTimeMilli(2020, 8, 5, 13, 14, 15, 0)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_CreateFromDateTimeMicro(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
CreateFromDateTimeMicro(2020, 8, 5, 13, 14, 15, 0)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_CreateFromDateTimeNano(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
CreateFromDateTimeNano(2020, 8, 5, 13, 14, 15, 0)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_CreateFromDate(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
CreateFromDate(2020, 8, 5)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_CreateFromDateMilli(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
CreateFromDateMilli(2020, 8, 5, 0)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_CreateFromDateMicro(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
CreateFromDateMicro(2020, 8, 5, 0)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_CreateFromDateNano(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
CreateFromDateNano(2020, 8, 5, 0)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_CreateFromTime(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
CreateFromTime(13, 14, 15)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_CreateFromTimeMilli(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
CreateFromTimeMilli(13, 14, 15, 0)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_CreateFromTimeMicro(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
CreateFromTimeMicro(13, 14, 15, 0)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_CreateFromTimeNano(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
CreateFromTimeNano(13, 14, 15, 0)
|
||||
}
|
||||
}
|
24
database_bench_test.go
Executable file
24
database_bench_test.go
Executable file
@ -0,0 +1,24 @@
|
||||
package carbon
|
||||
|
||||
import "testing"
|
||||
|
||||
func BenchmarkCarbon_Scan(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
_ = now.Scan(nil)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Value(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Value()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_GormDataType(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.GormDataType()
|
||||
}
|
||||
}
|
122
difference_bench_test.go
Executable file
122
difference_bench_test.go
Executable file
@ -0,0 +1,122 @@
|
||||
package carbon
|
||||
|
||||
import "testing"
|
||||
|
||||
func BenchmarkCarbon_DiffInYears(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.DiffInYears(Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_DiffAbsInYears(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.DiffAbsInYears(Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_DiffInMonths(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.DiffInMonths(Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_DiffAbsInMonths(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.DiffAbsInMonths(Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_DiffInWeeks(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.DiffInWeeks(Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_DiffAbsInWeeks(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.DiffAbsInWeeks(Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_DiffInDays(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.DiffInDays(Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_DiffAbsInDays(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.DiffAbsInDays(Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_DiffInHours(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.DiffInHours(Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_DiffAbsInHours(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.DiffAbsInHours(Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_DiffInMinutes(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.DiffInMinutes(Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_DiffAbsInMinutes(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.DiffAbsInMinutes(Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_DiffInSeconds(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.DiffInSeconds(Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_DiffAbsInSeconds(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.DiffAbsInSeconds(Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_DiffInString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.DiffInString(Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_DiffAbsInString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.DiffAbsInString(Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_DiffForHumans(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.DiffForHumans(Yesterday())
|
||||
}
|
||||
}
|
17
encoding_bench_test.go
Executable file
17
encoding_bench_test.go
Executable file
@ -0,0 +1,17 @@
|
||||
package carbon
|
||||
|
||||
import "testing"
|
||||
|
||||
func BenchmarkCarbon_MarshalJSON(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.MarshalJSON()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_UnmarshalJSON(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.UnmarshalJSON(nil)
|
||||
}
|
||||
}
|
17
extremum_bench_test.go
Executable file
17
extremum_bench_test.go
Executable file
@ -0,0 +1,17 @@
|
||||
package carbon
|
||||
|
||||
import "testing"
|
||||
|
||||
func BenchmarkCarbon_Closest(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Closest(Parse("2020-08-05"), Parse("2022-08-05"))
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Farthest(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Farthest(Parse("2020-08-05"), Parse("2022-08-05"))
|
||||
}
|
||||
}
|
297
getter_bench_test.go
Executable file
297
getter_bench_test.go
Executable file
@ -0,0 +1,297 @@
|
||||
package carbon
|
||||
|
||||
import "testing"
|
||||
|
||||
func BenchmarkCarbon_DaysInYear(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.DaysInYear()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_DaysInMonth(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.DaysInMonth()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_MonthOfYear(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.MonthOfYear()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_DayOfYear(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.DayOfYear()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_DayOfMonth(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.DayOfMonth()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_DayOfWeek(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.DayOfWeek()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_WeekOfYear(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.WeekOfYear()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_WeekOfMonth(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.WeekOfMonth()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_DateTime(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.DateTime()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_DateTimeMilli(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.DateTimeMilli()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_DateTimeMicro(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.DateTimeMilli()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_DateTimeNano(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.DateTimeNano()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Date(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Date()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_DateMilli(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.DateMilli()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_DateMicro(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.DateMicro()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_DateNano(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.DateNano()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Time(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Time()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_TimeMilli(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.TimeMilli()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_TimeMicro(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.TimeMicro()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_TimeNano(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.TimeNano()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Century(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Century()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Decade(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Decade()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Year(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Year()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Quarter(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Quarter()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Month(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Month()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Week(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Week()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Day(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Day()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Hour(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Hour()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Minute(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Minute()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Second(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Second()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Millisecond(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Millisecond()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Microsecond(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Microsecond()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Nanosecond(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Nanosecond()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Timestamp(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Timestamp()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_TimestampMilli(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.TimestampMilli()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_TimestampMicro(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.TimestampMicro()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_TimestampNano(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.TimestampNano()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Location(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Location()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Timezone(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Timezone()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Offset(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Offset()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Locale(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Locale()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Age(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Age()
|
||||
}
|
||||
}
|
38
language_bench_test.go
Executable file
38
language_bench_test.go
Executable file
@ -0,0 +1,38 @@
|
||||
package carbon
|
||||
|
||||
import "testing"
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
423
outputer_bench_test.go
Executable file
423
outputer_bench_test.go
Executable file
@ -0,0 +1,423 @@
|
||||
package carbon
|
||||
|
||||
import "testing"
|
||||
|
||||
func BenchmarkCarbon_String(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.String()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToMonthString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToMonthString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToShortMonthString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToShortMonthString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToWeekString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToWeekString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToShortWeekString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToWeekString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToDayDateTimeString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToDayDateTimeString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToDateTimeString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToDateTimeString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToDateTimeMilliString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToDateTimeMilliString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToDateTimeMicroString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToDateTimeMicroString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToDateTimeNanoString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToDateTimeNanoString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToShortDateTimeString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToShortDateTimeString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToShortDateTimeMilliString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToShortDateTimeString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToShortDateTimeMicroString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToShortDateTimeMicroString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToShortDateTimeNanoString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToShortDateTimeNanoString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToDateString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToDateString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToDateMilliString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToDateMilliString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToDateMicroString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToDateMicroString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToDateNanoString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToDateNanoString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToShortDateString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToShortDateString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToShortDateMilliString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToShortDateMilliString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToToShortDateMicroString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToShortDateMicroString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToShortDateNanoString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToShortDateNanoString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToTimeString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToTimeString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToTimeMilliString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToTimeMilliString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToTimeMicroString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToTimeMicroString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToTimeNanoString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToTimeNanoString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToShortTimeString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToShortTimeString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToShortTimeMilliString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToShortTimeMilliString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToShortTimeMicroString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToShortTimeMilliString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToShortTimeNanoString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToShortTimeNanoString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToAtomString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToAtomString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToAnsicString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToAnsicString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToCookieString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToCookieString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToRssString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToRssString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToW3cString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToW3cString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToUnixDateString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToUnixDateString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToRubyDateString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToRubyDateString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToKitchenString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToKitchenString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToIso8601String(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToIso8601String()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToIso8601MilliString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToIso8601MilliString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToIso8601MicroString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToIso8601MicroString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToIso8601NanoString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToIso8601NanoString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToRfc822String(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToRfc822String()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToRfc822zString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToRfc822zString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToRfc850String(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToRfc850String()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToRfc1036String(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToRfc1036String()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToRfc1123String(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToRfc1123String()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToRfc1123zString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToRfc1123zString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToRfc2822String(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToRfc2822String()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToRfc3339String(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToRfc2822String()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToRfc3339MilliString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToRfc3339MilliString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToRfc3339MicroString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToRfc3339MicroString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToRfc3339NanoString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToRfc3339NanoString()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToRfc7231String(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToRfc7231String()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToLayoutString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToLayoutString("2006-01-02", "2020-08-05")
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Layout(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Layout("2006-01-02", "2020-08-05")
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToFormatString(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToFormatString("2006-01-02", "Y-m-d")
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Format(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Format("2006-01-02", "Y-m-d")
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ToStdTime(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.ToStdTime()
|
||||
}
|
||||
}
|
21
parser_bench_test.go
Executable file
21
parser_bench_test.go
Executable file
@ -0,0 +1,21 @@
|
||||
package carbon
|
||||
|
||||
import "testing"
|
||||
|
||||
func BenchmarkCarbon_Parse(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
Parse("2020-08-05")
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ParseByFormat(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
ParseByFormat("2020-08-05", "Y-m-d")
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_ParseByLayout(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
ParseByLayout("2020-08-05", "2006-01-02")
|
||||
}
|
||||
}
|
52
season_bench_test.go
Executable file
52
season_bench_test.go
Executable file
@ -0,0 +1,52 @@
|
||||
package carbon
|
||||
|
||||
import "testing"
|
||||
|
||||
func BenchmarkCarbon_Season(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Season()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_StartOfSeason(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.StartOfSeason()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_EndOfSeason(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.EndOfSeason()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsSpring(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsSpring()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsSummer(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsSummer()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsAutumn(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsAutumn()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsWinter(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.IsWinter()
|
||||
}
|
||||
}
|
176
setter_bench_test.go
Executable file
176
setter_bench_test.go
Executable file
@ -0,0 +1,176 @@
|
||||
package carbon
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func BenchmarkCarbon_SetTimezone(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
SetTimezone(PRC)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SetLocation(b *testing.B) {
|
||||
loc, _ := time.LoadLocation(PRC)
|
||||
for n := 0; n < b.N; n++ {
|
||||
SetLocation(loc)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SetLocale(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
SetLocale("en")
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SetLanguage(b *testing.B) {
|
||||
lang := NewLanguage()
|
||||
for n := 0; n < b.N; n++ {
|
||||
c.SetLanguage(lang)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SetDateTime(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
c.SetDateTime(2020, 8, 5, 0, 0, 0)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SetDateTimeMilli(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
c.SetDateTimeMilli(2020, 8, 5, 0, 0, 0, 0)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SetDateTimeMicro(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
c.SetDateTimeMicro(2020, 8, 5, 0, 0, 0, 0)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SetDateTimeNano(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
c.SetDateTimeNano(2020, 8, 5, 0, 0, 0, 0)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SetDate(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
c.SetDate(2020, 8, 5)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SetDateMilli(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
c.SetDateMilli(2020, 8, 5, 0)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SetDateMicro(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
c.SetDateMicro(2020, 8, 5, 0)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SetDateNano(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
c.SetDateNano(2020, 8, 5, 0)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SetTime(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
c.SetTime(13, 14, 15)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SetTimeMilli(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
c.SetTimeMilli(13, 14, 15, 0)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SetTimeMicro(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
c.SetTimeMicro(13, 14, 15, 0)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SetTimeNano(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
c.SetTimeNano(13, 14, 15, 0)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SetYear(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
c.SetYear(2020)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SetYearNoOverflow(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
c.SetYearNoOverflow(2020)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SetMonth(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
c.SetMonth(8)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SetMonthNoOverflow(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
c.SetMonthNoOverflow(8)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SetWeekStartsAt(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
c.SetWeekStartsAt(Sunday)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SetDay(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
c.SetDay(20)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SetHour(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
c.SetHour(20)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SetMinute(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
c.SetMinute(20)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SetSecond(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
c.SetSecond(20)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SetMillisecond(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
c.SetMillisecond(20)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SetMicrosecond(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
c.SetMicrosecond(20)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SetNanosecond(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
c.SetNanosecond(20)
|
||||
}
|
||||
}
|
29
tag_bench_test.go
Executable file
29
tag_bench_test.go
Executable file
@ -0,0 +1,29 @@
|
||||
package carbon
|
||||
|
||||
import "testing"
|
||||
|
||||
func BenchmarkCarbon_Tag(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.Tag()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SetTag(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SetTag("layout:2006-01-02")
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_LoadTag(b *testing.B) {
|
||||
type Student struct {
|
||||
Birthday Carbon `json:"birthday" carbon:"date"`
|
||||
}
|
||||
student := Student{
|
||||
Birthday: Now(),
|
||||
}
|
||||
for n := 0; n < b.N; n++ {
|
||||
_ = LoadTag(&student)
|
||||
}
|
||||
}
|
21
test_bench_test.go
Executable file
21
test_bench_test.go
Executable file
@ -0,0 +1,21 @@
|
||||
package carbon
|
||||
|
||||
import "testing"
|
||||
|
||||
func BenchmarkCarbon_SetTestNow(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
c.SetTestNow(Yesterday())
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_UnSetTestNow(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
c.UnSetTestNow()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_IsSetTestNow(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
c.IsSetTestNow()
|
||||
}
|
||||
}
|
539
traveler_bench_test.go
Executable file
539
traveler_bench_test.go
Executable file
@ -0,0 +1,539 @@
|
||||
package carbon
|
||||
|
||||
import "testing"
|
||||
|
||||
func BenchmarkCarbon_Now(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
Now()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Yesterday(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
Yesterday()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_Tomorrow(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
Tomorrow()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddDuration(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddDuration("1s")
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubDuration(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubDuration("1s")
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddCenturies(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddCenturies(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddCenturiesNoOverflow(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddCenturiesNoOverflow(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddCentury(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddCentury()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddCenturyNoOverflow(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddCenturyNoOverflow()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubCenturies(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubCenturies(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubCenturiesNoOverflow(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubCenturiesNoOverflow(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubCentury(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubCentury()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubCenturyNoOverflow(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubCenturyNoOverflow()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddDecades(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddDecades(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddDecadesNoOverflow(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddDecadesNoOverflow(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddDecade(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddDecade()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddDecadeNoOverflow(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddDecadeNoOverflow()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubDecades(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubDecades(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubDecadesNoOverflow(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubDecadesNoOverflow(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubDecade(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubDecade()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubDecadeNoOverflow(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubDecadeNoOverflow()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddYears(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddYears(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddYearsNoOverflow(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddYearsNoOverflow(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddYear(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddYear()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddYearNoOverflow(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddYearNoOverflow()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubYears(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubYears(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubYearsNoOverflow(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubYearsNoOverflow(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubYear(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubYear()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubYearNoOverflow(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubYearNoOverflow()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddQuarters(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddQuarters(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddQuartersNoOverflow(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddQuartersNoOverflow(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddQuarter(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddQuarter()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddQuarterNoOverflow(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddQuarter()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubQuarters(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubQuarters(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubQuartersNoOverflow(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubQuartersNoOverflow(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubQuarter(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubQuarter()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubQuarterNoOverflow(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubQuarterNoOverflow()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddMonths(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddMonths(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddMonthsNoOverflow(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddMonthsNoOverflow(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddMonth(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddMonth()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddMonthNoOverflow(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddMonthNoOverflow()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubMonths(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubMonths(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubMonthsNoOverflow(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubMonthsNoOverflow(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubMonth(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubMonth()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubMonthNoOverflow(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubMonthNoOverflow()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddWeeks(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddWeeks(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddWeek(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddWeek()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubWeeks(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubWeeks(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubWeek(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubWeek()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddDays(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddDays(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddDay(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddDay()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubDays(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubDays(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubDay(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubDay()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddHours(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddHours(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddHour(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddHour()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubHours(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubHours(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubHour(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubHour()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddMinutes(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddMinutes(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddMinute(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddMinute()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubMinutes(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubMinutes(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubMinute(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubMinute()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddSeconds(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddSeconds(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddSecond(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddSecond()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubSeconds(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubSeconds(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubSecond(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubSecond()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddMilliseconds(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddMilliseconds(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddMillisecond(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddMillisecond()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubMilliseconds(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubMilliseconds(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubMillisecond(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubMillisecond()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddMicroseconds(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddMicroseconds(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddMicrosecond(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddMicrosecond()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubMicroseconds(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubMicroseconds(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubMicrosecond(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubMicrosecond()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddNanoseconds(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddNanoseconds(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_AddNanosecond(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.AddNanosecond()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubNanoseconds(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubNanoseconds(1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCarbon_SubNanosecond(b *testing.B) {
|
||||
now := Now()
|
||||
for n := 0; n < b.N; n++ {
|
||||
now.SubNanosecond()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user