[Mono-dev] DateTime.Now performance improvement.

Miguel de Icaza miguel at ximian.com
Tue Nov 21 18:08:19 EST 2006


    I forgot to mention, with this change, a tight loop calling
DateTime.Now will go from 19.96 seconds to do one million calls into
14.21, so 5.75 seconds less.

    Am doing a larger change that will improve Now performance more.

> Hello,
>     The following patch helps in improving the performance of
> DateTime.Now.   
>     DateTime.Now does a lot of work currently as it needs to convert a
> system time into the local time zone.  This patch caches a common value:
> the current year at the time of initialization, and uses that fast code
> path instead of the slower one most of the time.
>     People running software that crosses the year boundary will still
> get the slower version, I could fix that if we think its important.
> Miguel.

More information about the Mono-devel-list mailing list