Home » Community » Coffee corner » Optimizing svo_memeq -- just for curiosity
Optimizing svo_memeq -- just for curiosity [message #42267] |
Mon, 03 March 2014 16:32 |
Tom1
Messages: 1212 Registered: March 2007
|
Senior Contributor |
|
|
Hi,
I tinkered a bit with svo_memeq (svo_memeq_t below) and found that simplifying the code a bit may improve performance dramatically when compiled with MSC9/MSC10 Speed -build mode:
template <class tchar>
force_inline bool svo_memeq_t(const tchar *a, const tchar *b, int len){
return !len-- ? true : *a++!=*b++ ? false : svo_memeq_t(a,b,len);
}
Short lengths can get an about five or six fold improvement and bigger lengths (over 12) are even better. (Anyway, this what I found on Windows on an Intel processor.)
OK, this is recursive and stack can't handle unlimited comparison lengths, so this can't replace the original code as is. So, this is just for those interested in how compilers' optimization work.
Best regards,
Tom
|
|
|
Goto Forum:
Current Time: Fri Apr 26 12:05:28 CEST 2024
Total time taken to generate the page: 0.03650 seconds
|