Re: [boost] [String algorithm] is_any_of has inefficient

In each case, I've used the predicate with std::find_if. But if I instead use C's strcspn() to do the whole job, I see a relative performance for this example of 20. I find it depressing that the C++ code doesn't come close to that.
Well, it is not really a fair comparison, the 'C' function is likely implemented in hand optimized assembler, (http://tinyurl.com/yv8s7g) and for such a small function, humans are still better than compilers. So it isn't really C++ versus C. Also the C version is not generic at all.
Personally, I feel that generic C++ code should at least avoid having inferior complexity, compared to the corresponding C code! And I am very happy to see that you are interested in these performance issues. I have done a relative research regarding the performance of the find_first_of algorithm [1] and my findings were rather similar to the findings of Phil Endecott. Fortunately, I have also found that using a (bit/byte) array for mapping, find_first_of can achieve the same complexity (of -course) and similar performance compared to the specialized C code. Of course, in order to achieve these performance gains, you have to implement specializations. Equivalently, I believe that using bit-arrays instead of sets in the is_any_of is a very good thing, as long as you are actually improving the time complexity. References 1. http://www.codeproject.com/KB/stl/find_first_of.aspx Best regards, Jim Xochellis ___________________________________________________________ Χρησιμοποιείτε Yahoo!; Βαρεθήκατε τα ενοχλητικά μηνύματα (spam); Το Yahoo! Mail διαθέτει την καλύτερη δυνατή προστασία κατά των ενοχλητικών μηνυμάτων http://login.yahoo.com/config/mail?.intl=gr
participants (1)
-
dpxguard-boost@yahoo.gr