houseabsolute / Time-Local

Efficiently compute time from local and GMT time
https://metacpan.org/release/Time-Local/
Other
4 stars 11 forks source link

time*_modern() without checking #9

Closed ppisar closed 4 years ago

ppisar commented 5 years ago

Time::Local recommends time_modern functions because of an unambiguous interpretation of the year value. Time::Local also provides time_nocheck functions that promise a faster code.

I'm missing an interface that is unambiguous and fast at the same time. Could you consider adding one? Or is setting $Time::Local::Options{no_range_check} and using time*_modern good enough?

autarch commented 5 years ago

Yes, setting the no_range_check key to true would do the trick. That said, I'd be happy to accept a PR to add time{gm,local}_modern_nocheck variants.

Grinnz commented 4 years ago

It might be nice to add a more general way to pass options to a timelocal() or timegm() call especially if there will also be the functions added in #13.

autarch commented 4 years ago

So I looked into this some more. My benchmarks show a mere 3% increase when using the nocheck variants. So unless your code base consists mostly of calls to Time::Local, using a nocheck variant won't make much difference.

I suspect that back in the day, the difference was much greater, but on modern systems it seems like it's not worth the effort.

ppisar commented 4 years ago

Fair enough.