This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] _mktm_r: optimize speed


I attach patch (with ChangeLog entry) for _mktm_r() which replaces iterative calculations of day with a few divisions and multiplications.

This change results in the function working two times faster on ARM Cortex-M3 microcontroller - one million calls of "old" function using random numbers take ~70s, while the same calculations with "new" code take ~33s (clock of chip is 16MHz). Obviously the improvement depends on the input value - sometimes the patched code can be slower than the old one - for input values "close" to year 1970. On the other hand, the "further" from 1970, the bigger is the performance gain.

Both versions give the same results - tested with a few million random numbers - both versions were called for the same input value and result was compared with memcmp().

Regards,
FCh

Attachment: ChangeLog.txt
Description: Text document

Attachment: 0001-_mktm_r-optimize-speed.patch
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]