You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Moreover, std::minmax_element is slower than calling std::min_element+std::max_element if there's a lot of data and it does not fit into the CPU cache: http://quick-bench.com/tlgxCx9CUMZgOfYbwhFaEI0WNOg
The text was updated successfully, but these errors were encountered:
However, it looks like there's still a room for improvement. If std::minmax_element is called with standard comparators and for fundamental type, then using a simple loop (with more comparisons) will improve performance (for CPUs that have branch predictors and non costly comparison instructions for builtins).
Although I'm not sure that this could/should be solved on the library level - too many CPU specific knowledge in libc++ does not seem right.
That's better; but you are testing different things.
Your "hand written code" returns (in pointers) two values.
The "standard one" returns a pair of iterators.
Also, despite being faster, you're doing more comparisons than the one in the standard:
You: 2N comparisons.
Std: 3N/2 comparisons.
Extended Description
Moreover, std::minmax_element is slower than calling std::min_element+std::max_element if there's a lot of data and it does not fit into the CPU cache: http://quick-bench.com/tlgxCx9CUMZgOfYbwhFaEI0WNOg
The text was updated successfully, but these errors were encountered: