spatie / period

Complex period comparisons
https://spatie.be/open-source
MIT License
1.55k stars 72 forks source link

Don't initialize Period::asString in constructor #94

Closed endelwar closed 2 years ago

endelwar commented 2 years ago

When working with large PeriodCollections (300-400 Period objects each) initializing asString variable in Period __construct() slows down PeriodCollection operation as subtract() and overlapAll(). With this patch, I've obtained a -16% CPU time in my batch command (going from 4min 35sec to 3min 51sec).

Schermata 2021-10-06 alle 18 59 11
endelwar commented 2 years ago

Updated check and rebased on 2.1.2

brendt commented 2 years ago

Thanks!

brendt commented 2 years ago

Released here: https://github.com/spatie/period/releases/tag/2.1.3

endelwar commented 2 years ago

Thanks to you!