1 <!doctype html public
"-//w3c//dtd html 4.0 transitional//en">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=iso-8859-1">
5 <meta name=
"GENERATOR" content=
"Mozilla/4.77 [en] (X11; U; Linux 2.2.19 i686) [Netscape]">
6 <meta name=
"Author" content=
"Herve Bronnimann">
7 <meta name=
"Description" content=
"Small library to propose minmax_element algorithm.">
8 <title>Boost minmax library
</title>
10 <body text=
"#000000" bgcolor=
"#FFFFFF" link=
"#0000EE" vlink=
"#551A8B" alink=
"#FF0000">
14 Minmax_element Performance
</h1></center>
17 <a NAME=
"Performance"></a><b>About performance
</b></h3>
18 Of course, there are many factors that affect the performance of an algorithm.
19 The number of comparison is only one, but also branch prediction, pipelining,
20 locality of reference (affects cache efficiency), etc. In practice,
21 we observe that when the iterator type is a pointer,
22 <tt>boost::minmax_element
</tt>
23 is only a tad slower than
24 <tt>std::min_element
</tt>, and is even faster
26 <tt>boost::first_min_last_max_element
</tt>! This is even more true
27 for slower iterators (
<tt>list
<>::iterator
</tt> or
28 <tt>map
<>iterator
</tt>
29 for instance). The following experiments were conducted on a Pentium III
30 500 Mhz running Linux and compiled with g++, version
2.95.2, flags -O3.
31 In the tables, we use different distributions:
<i>Identical
</i> means that
32 all the elements are identical,
<i>2-valued
</i> means that we replace the
33 second half of the identical elements by a distinct element,
<i>increasing
</i>
34 means that all the elements are distinct and in increasing order,
<i>decrea
</i>sing
35 is the reverse, and
<i>random
</i> is produced by random_shuffle.
37 The program that created these tables is included in the distribution,
38 under
<a href=
"../example/minmax_timer.cpp">minmax_timer.cpp
</a>
40 <center><table BORDER NOSAVE
>
42 <td NOSAVE
><b>vector
<int
>::iterator
</b></td>
56 <td>std::min_element
</td>
70 <td>std::max_element
</td>
84 <td>boost::first_min_element
</td>
98 <td>boost::last_min_element
</td>
112 <td>boost::first_max_element
</td>
126 <td>boost::last_max_element
</td>
140 <td>boost::minmax_element
</td>
154 <td>boost::first_min_last_max_element
</td>
168 <td>boost::last_min_first_max_element
</td>
182 <td>boost::last_min_last_max_element
</td>
195 <caption ALIGN=BOTTOM
>Number of elements per second for standard vector
196 container iterators
</caption>
199 <center><table BORDER NOSAVE
>
201 <td NOSAVE
><b>list
<int
>::iterator
</b></td>
215 <td>std::min_element
</td>
229 <td>std::max_element
</td>
243 <td>boost::first_min_element
</td>
257 <td>boost::last_min_element
</td>
271 <td>boost::first_max_element
</td>
285 <td>boost::last_max_element
</td>
299 <td>boost::minmax_element
</td>
313 <td>boost::first_min_last_max_element
</td>
327 <td>boost::last_min_first_max_element
</td>
341 <td>boost::last_min_last_max_element
</td>
354 <caption ALIGN=BOTTOM
>Runtimes for standard list container iterators
</caption>
357 <center><table BORDER NOSAVE
>
359 <td NOSAVE
><b>multiset
<int
>::iterator
</b></td>
373 <td>std::min_element
</td>
387 <td>std::max_element3.007M
</td>
401 <td>boost::first_min_element
</td>
415 <td>boost::last_min_element
</td>
429 <td>boost::first_max_element
</td>
443 <td>boost::last_max_element
</td>
457 <td>boost::minmax_element
</td>
471 <td>boost::first_min_last_max_element
</td>
485 <td>boost::last_min_first_max_element
</td>
499 <td>boost::last_min_last_max_element
</td>
512 <caption ALIGN=BOTTOM
>Runtimes for standard set/multiset container iterators
</caption>
516 <br>Last modified
2004-
06-
28
517 <p><font face=
"Arial,Helvetica"><font size=-
1>© Copyright Herv
é
518 Br
önnimann, Polytechnic University,
2002--
2004.
519 Use, modification, and distribution is subject to the Boost Software
520 License, Version
1.0. (See accompanying file
<a href=
"../../../../LICENSE_1_0.txt">License_1_0.txt
</a> or copy at
521 <a href=
"http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt
</a>)