carbon/boundary_bench_test.go

206 lines
3.5 KiB
Go
Raw Normal View History

2023-12-28 11:27:27 +08:00
package carbon
import (
"testing"
)
func BenchmarkCarbon_StartOfCentury(b *testing.B) {
now := Now()
2024-01-02 23:21:50 +08:00
for n := 0; n < b.N; n++ {
NewCarbon().StartOfCentury()
}
2023-12-28 11:27:27 +08:00
for n := 0; n < b.N; n++ {
now.StartOfCentury()
}
}
func BenchmarkCarbon_EndOfCentury(b *testing.B) {
now := Now()
2024-01-02 23:21:50 +08:00
for n := 0; n < b.N; n++ {
NewCarbon().EndOfCentury()
}
2023-12-28 11:27:27 +08:00
for n := 0; n < b.N; n++ {
now.EndOfCentury()
}
}
func BenchmarkCarbon_StartOfDecade(b *testing.B) {
now := Now()
2024-01-02 23:21:50 +08:00
for n := 0; n < b.N; n++ {
NewCarbon().StartOfDecade()
}
2023-12-28 11:27:27 +08:00
for n := 0; n < b.N; n++ {
now.StartOfDecade()
}
}
func BenchmarkCarbon_EndOfDecade(b *testing.B) {
now := Now()
2024-01-02 23:21:50 +08:00
for n := 0; n < b.N; n++ {
NewCarbon().EndOfDecade()
}
2023-12-28 11:27:27 +08:00
for n := 0; n < b.N; n++ {
now.EndOfDecade()
}
}
func BenchmarkCarbon_StartOfYear(b *testing.B) {
now := Now()
2024-01-02 23:21:50 +08:00
for n := 0; n < b.N; n++ {
NewCarbon().StartOfYear()
}
2023-12-28 11:27:27 +08:00
for n := 0; n < b.N; n++ {
now.StartOfYear()
}
}
func BenchmarkCarbon_EndOfYear(b *testing.B) {
now := Now()
2024-01-02 23:21:50 +08:00
for n := 0; n < b.N; n++ {
NewCarbon().EndOfYear()
}
2023-12-28 11:27:27 +08:00
for n := 0; n < b.N; n++ {
now.EndOfYear()
}
}
func BenchmarkCarbon_StartOfQuarter(b *testing.B) {
now := Now()
2024-01-02 23:21:50 +08:00
for n := 0; n < b.N; n++ {
NewCarbon().StartOfQuarter()
}
2023-12-28 11:27:27 +08:00
for n := 0; n < b.N; n++ {
now.StartOfQuarter()
}
}
func BenchmarkCarbon_EndOfQuarter(b *testing.B) {
now := Now()
2024-01-02 23:21:50 +08:00
for n := 0; n < b.N; n++ {
NewCarbon().EndOfQuarter()
}
2023-12-28 11:27:27 +08:00
for n := 0; n < b.N; n++ {
now.EndOfQuarter()
}
}
func BenchmarkCarbon_StartOfMonth(b *testing.B) {
now := Now()
2024-01-02 23:21:50 +08:00
for n := 0; n < b.N; n++ {
NewCarbon().StartOfMonth()
}
2023-12-28 11:27:27 +08:00
for n := 0; n < b.N; n++ {
now.StartOfMonth()
}
}
func BenchmarkCarbon_EndOfMonth(b *testing.B) {
now := Now()
2024-01-02 23:21:50 +08:00
for n := 0; n < b.N; n++ {
NewCarbon().EndOfMonth()
}
2023-12-28 11:27:27 +08:00
for n := 0; n < b.N; n++ {
now.EndOfMonth()
}
}
func BenchmarkCarbon_StartOfWeek(b *testing.B) {
now := Now()
2024-01-02 23:21:50 +08:00
for n := 0; n < b.N; n++ {
NewCarbon().StartOfWeek()
}
2023-12-28 11:27:27 +08:00
for n := 0; n < b.N; n++ {
now.StartOfWeek()
}
}
func BenchmarkCarbon_EndOfWeek(b *testing.B) {
now := Now()
2024-01-02 23:21:50 +08:00
for n := 0; n < b.N; n++ {
NewCarbon().EndOfWeek()
}
2023-12-28 11:27:27 +08:00
for n := 0; n < b.N; n++ {
now.EndOfWeek()
}
}
func BenchmarkCarbon_StartOfDay(b *testing.B) {
now := Now()
2024-01-02 23:21:50 +08:00
for n := 0; n < b.N; n++ {
NewCarbon().StartOfDay()
}
2023-12-28 11:27:27 +08:00
for n := 0; n < b.N; n++ {
now.StartOfDay()
}
}
func BenchmarkCarbon_EndOfDay(b *testing.B) {
now := Now()
2024-01-02 23:21:50 +08:00
for n := 0; n < b.N; n++ {
NewCarbon().EndOfDay()
}
2023-12-28 11:27:27 +08:00
for n := 0; n < b.N; n++ {
now.EndOfDay()
}
}
func BenchmarkCarbon_StartOfHour(b *testing.B) {
now := Now()
2024-01-02 23:21:50 +08:00
for n := 0; n < b.N; n++ {
NewCarbon().StartOfHour()
}
2023-12-28 11:27:27 +08:00
for n := 0; n < b.N; n++ {
now.StartOfHour()
}
}
func BenchmarkCarbon_EndOfHour(b *testing.B) {
now := Now()
2024-01-02 23:21:50 +08:00
for n := 0; n < b.N; n++ {
NewCarbon().EndOfHour()
}
2023-12-28 11:27:27 +08:00
for n := 0; n < b.N; n++ {
now.EndOfHour()
}
}
func BenchmarkCarbon_StartOfMinute(b *testing.B) {
now := Now()
2024-01-02 23:21:50 +08:00
for n := 0; n < b.N; n++ {
NewCarbon().StartOfMinute()
}
2023-12-28 11:27:27 +08:00
for n := 0; n < b.N; n++ {
now.StartOfMinute()
}
}
func BenchmarkCarbon_EndOfMinute(b *testing.B) {
now := Now()
2024-01-02 23:21:50 +08:00
for n := 0; n < b.N; n++ {
NewCarbon().EndOfMinute()
}
2023-12-28 11:27:27 +08:00
for n := 0; n < b.N; n++ {
now.EndOfMinute()
}
}
func BenchmarkCarbon_StartOfSecond(b *testing.B) {
now := Now()
2024-01-02 23:21:50 +08:00
for n := 0; n < b.N; n++ {
NewCarbon().StartOfSecond()
}
2023-12-28 11:27:27 +08:00
for n := 0; n < b.N; n++ {
now.StartOfSecond()
}
}
func BenchmarkCarbon_EndOfSecond(b *testing.B) {
now := Now()
2024-01-02 23:21:50 +08:00
for n := 0; n < b.N; n++ {
NewCarbon().EndOfSecond()
}
2023-12-28 11:27:27 +08:00
for n := 0; n < b.N; n++ {
now.EndOfSecond()
}
}