1 // Copyright (C) 2013-2015 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
20 #include <testsuite_performance.h>
24 using namespace __gnu_test
;
27 resource_counter resource
;
29 const int max_size
= 10000000;
31 std::vector
<int> v(max_size
);
33 for (int i
= 0; i
< max_size
; ++i
)
36 start_counters(time
, resource
);
37 std::make_heap(v
.begin(), v
.end());
38 stop_counters(time
, resource
);
40 report_performance(__FILE__
, "make_heap_reverse", time
, resource
);
41 clear_counters(time
, resource
);
43 for (int i
= 0; i
< max_size
; ++i
)
46 start_counters(time
, resource
);
47 std::make_heap(v
.begin(), v
.end());
48 stop_counters(time
, resource
);
50 report_performance(__FILE__
, "make_heap_forwards", time
, resource
);
51 clear_counters(time
, resource
);
53 // a simple psuedo-random series which does not rely on rand() and friends
55 for (int i
= 1; i
< max_size
; ++i
)
56 v
[i
] = (v
[i
-1] + 110211473) * 745988807;
58 start_counters(time
, resource
);
59 std::make_heap(v
.begin(), v
.end());
60 stop_counters(time
, resource
);
62 report_performance(__FILE__
, "make_heap_random", time
, resource
);
65 start_counters(time
, resource
);
66 std::sort_heap(v
.begin(), v
.end());
67 stop_counters(time
, resource
);
69 report_performance(__FILE__
, "sort_heap", time
, resource
);
70 clear_counters(time
, resource
);