(Using NodaTime 2.0.2 in a release-built app on netfx 4.6.1 w. VS2017)
I've been profiling an app which reads log files containing about 100000 records that include a time_t-style timestamp.
Since upgrading to NodaTime2 we've been converting these timestamps to Instant using Instant.FromUnixTimeSeconds.
It appears that this function is actually quite time-consuming, at least when it chooses to use BigInteger internally - reverting to something like _epoch.PlusNanoseconds(time_t * 1000000000L) (where _epoch is a static Instant in 1970) has just given us an enormous speed-up on the app (roughly 2:1 on the whole file processing routine, which was a considerable surprise).
It seems like Duration operator * has some logic to try and avoid BigInteger if it can, but it would appear in our case that BigInteger can be avoided but Duration has not chosen to do so.
I have not yet tried to calculate all the limits here, but is the very poor performance of BigInteger just a fact of life, and are there situations where could be avoided but isn't?
Here's a bit of DotTrace which might be useful.

(Using NodaTime 2.0.2 in a release-built app on netfx 4.6.1 w. VS2017)
I've been profiling an app which reads log files containing about 100000 records that include a time_t-style timestamp.
Since upgrading to NodaTime2 we've been converting these timestamps to
InstantusingInstant.FromUnixTimeSeconds.It appears that this function is actually quite time-consuming, at least when it chooses to use BigInteger internally - reverting to something like
_epoch.PlusNanoseconds(time_t * 1000000000L)(where _epoch is a staticInstantin 1970) has just given us an enormous speed-up on the app (roughly 2:1 on the whole file processing routine, which was a considerable surprise).It seems like
Duration operator *has some logic to try and avoidBigIntegerif it can, but it would appear in our case that BigInteger can be avoided but Duration has not chosen to do so.I have not yet tried to calculate all the limits here, but is the very poor performance of BigInteger just a fact of life, and are there situations where could be avoided but isn't?
Here's a bit of DotTrace which might be useful.