carbon/tag_bench_test.go

26 lines
417 B
Go
Raw Normal View History

2023-12-28 11:27:27 +08:00
package carbon
import "testing"
2024-01-12 10:57:10 +08:00
func BenchmarkCarbon_SetTag(b *testing.B) {
2023-12-28 11:27:27 +08:00
now := Now()
for n := 0; n < b.N; n++ {
2024-01-07 20:03:45 +08:00
now.SetTag(&tag{
2024-01-02 23:21:50 +08:00
carbon: "datetime",
tz: Local,
})
2023-12-28 11:27:27 +08:00
}
}
func BenchmarkCarbon_LoadTag(b *testing.B) {
type Student struct {
2024-01-12 10:57:10 +08:00
Birthday Carbon `json:"birthday" carbon:"type:date"`
2023-12-28 11:27:27 +08:00
}
student := Student{
Birthday: Now(),
}
for n := 0; n < b.N; n++ {
_ = LoadTag(&student)
}
}