teambition / rrule-go

Go library for working with recurrence rules for calendar dates.
MIT License
310 stars 57 forks source link

rrule iterator speedup #51

Closed to6ka closed 2 years ago

to6ka commented 2 years ago

master:

go test -benchmem -bench=.

BenchmarkIterator/simple_secondly-16                2314            505705 ns/op          626062 B/op        803 allocs/op
BenchmarkIterator/simple_minutely-16                2151            535967 ns/op          630885 B/op       1004 allocs/op
BenchmarkIterator/simple_hourly-16                  2136            536103 ns/op          630886 B/op       1004 allocs/op
BenchmarkIterator/simple_daily-16                   2298            475877 ns/op          621238 B/op        602 allocs/op
BenchmarkIterator/simple_weekly-16                  2084            569729 ns/op          630822 B/op       1800 allocs/op
BenchmarkIterator/simple_monthly-16                 1352            846036 ns/op          668348 B/op       6491 allocs/op
BenchmarkIterator/simple_yearly-16                   304           3631130 ns/op         1204037 B/op      73451 allocs/op

optimized:

go test -benchmem -bench=.

BenchmarkIterator/simple_secondly-16               62395             18023 ns/op             528 B/op          5 allocs/op
BenchmarkIterator/simple_minutely-16               43671             28795 ns/op            2952 B/op        106 allocs/op
BenchmarkIterator/simple_hourly-16                 43428             26932 ns/op            2952 B/op        106 allocs/op
BenchmarkIterator/simple_daily-16                  73759             15702 ns/op             504 B/op          4 allocs/op
BenchmarkIterator/simple_weekly-16                 51996             23094 ns/op             680 B/op          5 allocs/op
BenchmarkIterator/simple_monthly-16                24918             47688 ns/op            1000 B/op          4 allocs/op
BenchmarkIterator/simple_yearly-16                  5096            249395 ns/op            6632 B/op          4 allocs/op

iterator call faster 7x -15x memory consumption decreased 200x - 1200x

zensh commented 2 years ago

Great work! Thank you @to6ka