You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's very important for us at Duffel speedup the duration
parsing. We're were investigating this function and we
noticed a big number of calls to String.contains? that is
a O(n) order algorithm in a loop.
So we did a quick experiment on putting a flag on the number
type while reading the chars. So it assumes that is a integer,
until find a dot, where it changes the type to float. Then, it
parses using Float or Integer depending on the flag. Avoiding
the String.contains calls.
The results were quite interesting:
Before
Timex.Duration.parse 500000 3322687 ~6.65µs/op
Timex.Duration.parse 500000 1710993 ~3.42µs/op
0 commit comments