srawlins / timezone

Time zone database and time zone aware DateTime object for Dart.
BSD 2-Clause "Simplified" License
102 stars 53 forks source link

Initializing the database can take a long time #134

Open mkustermann opened 2 years ago

mkustermann commented 2 years ago

We have an internal user that uses constant data to initialize package:timezone library. Due to lack of constant byte-array literals in the language, it uses a 400 KB string (close to half megabyte!), base64 decodes it and uses initializeDatabase.

This process can take 1ms on a fast modern workstation and probably 10ms+ on a mobile device. Since this is all done eagerly and synchronously, this is not very ideal - especially for startup performance.

It would be interesting to see if this could be done at compile-time: Take a data file and produce dart code that makes const Location(), const Timezone() objects. The main question is whether this would make the app significantly larger or not for common data files.

mkustermann commented 2 years ago

Alternatively one could imagine having a format that allows lazily loading just the pieces that are needed.