Skip to content

Commit

Permalink
add benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
luxifer committed Nov 7, 2023
1 parent 33aa5b6 commit acd440d
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ func TestParse(t *testing.T) {
}
}

func BenchmarkParse(b *testing.B) {
for _, filename := range calendarList {
file, _ := os.Open(filename)
info, _ := file.Stat()

b.Run(filename, func(b *testing.B) {
b.SetBytes(info.Size())
for n := 0; n < b.N; n++ {
_, _ = Parse(file, nil)
}
})
}
}

func Test_parseDate(t *testing.T) {
loc, _ := time.LoadLocation("America/New_York")
type args struct {
Expand All @@ -39,7 +53,7 @@ func Test_parseDate(t *testing.T) {
prop: &Property{
Name: "DTSTART",
Params: map[string]*Param{
"VALUE": &Param{
"VALUE": {
Values: []string{"DATE"},
},
},
Expand All @@ -55,7 +69,7 @@ func Test_parseDate(t *testing.T) {
prop: &Property{
Name: "DTSTART",
Params: map[string]*Param{
"TZID": &Param{
"TZID": {
Values: []string{"America/New_York"},
},
},
Expand Down Expand Up @@ -93,7 +107,7 @@ func Test_parseDate(t *testing.T) {
prop: &Property{
Name: "DSTART",
Params: map[string]*Param{
"VALUE": &Param{
"VALUE": {
Values: []string{"DATE-TIME"},
},
},
Expand All @@ -109,7 +123,7 @@ func Test_parseDate(t *testing.T) {
prop: &Property{
Name: "DTSTART",
Params: map[string]*Param{
"TZID": &Param{
"TZID": {
Values: []string{"Z"},
},
},
Expand Down

0 comments on commit acd440d

Please sign in to comment.