/*============================================================================= Copyright (c) 2010 Tim Blechmann Use, modification and distribution is subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ #include #include #include "../../../boost/heap/d_ary_heap.hpp" #include "../../../boost/heap/pairing_heap.hpp" #include "../../../boost/heap/fibonacci_heap.hpp" #include "../../../boost/heap/binomial_heap.hpp" #include "../../../boost/heap/skew_heap.hpp" #include "heap_benchmarks.hpp" using namespace std; template void run_benchmarks_immutable(void) { for (int i = 4; i != max_data; ++i) { for (int j = 0; j != 8; ++j) { int size = 1<= 4) size += (1<<(i-1)); cout << size << "\t"; { typedef typename benchmark_selector:: template rebind > > ::type benchmark_functor; benchmark_functor benchmark(size); double result = run_benchmark(benchmark); cout << result << '\t'; } { typedef typename benchmark_selector:: template rebind, boost::heap::mutable_ > > ::type benchmark_functor; benchmark_functor benchmark(size); double result = run_benchmark(benchmark); cout << result << '\t'; } { typedef typename benchmark_selector:: template rebind > > ::type benchmark_functor; benchmark_functor benchmark(size); double result = run_benchmark(benchmark); cout << result << '\t'; } { typedef typename benchmark_selector:: template rebind, boost::heap::mutable_ > > ::type benchmark_functor; benchmark_functor benchmark(size); double result = run_benchmark(benchmark); cout << result << '\t'; } { typedef typename benchmark_selector:: template rebind > > ::type benchmark_functor; benchmark_functor benchmark(size); double result = run_benchmark(benchmark); cout << result << '\t'; } { typedef typename benchmark_selector:: template rebind, boost::heap::mutable_ > > ::type benchmark_functor; benchmark_functor benchmark(size); double result = run_benchmark(benchmark); cout << result << '\t'; } { typedef typename benchmark_selector:: template rebind > ::type benchmark_functor; benchmark_functor benchmark(size); double result = run_benchmark(benchmark); cout << result << '\t'; } { typedef typename benchmark_selector:: template rebind > ::type benchmark_functor; benchmark_functor benchmark(size); double result = run_benchmark(benchmark); cout << result << '\t'; } { typedef typename benchmark_selector:: template rebind > ::type benchmark_functor; benchmark_functor benchmark(size); double result = run_benchmark(benchmark); cout << result << '\t'; } { typedef typename benchmark_selector:: template rebind > ::type benchmark_functor; benchmark_functor benchmark(size); double result = run_benchmark(benchmark); cout << result << '\t'; } { typedef typename benchmark_selector:: template rebind > ::type benchmark_functor; benchmark_functor benchmark(size); double result = run_benchmark(benchmark); cout << result << '\t'; } cout << endl; } } } template void run_benchmarks_mutable(void) { for (int i = 4; i != max_data; ++i) { for (int j = 0; j != 8; ++j) { int size = 1<= 4) size += (1<<(i-1)); cout << size << "\t"; { typedef typename benchmark_selector:: template rebind, boost::heap::mutable_ > > ::type benchmark_functor; benchmark_functor benchmark(size); double result = run_benchmark(benchmark); cout << result << '\t'; } { typedef typename benchmark_selector:: template rebind, boost::heap::mutable_ > > ::type benchmark_functor; benchmark_functor benchmark(size); double result = run_benchmark(benchmark); cout << result << '\t'; } { typedef typename benchmark_selector:: template rebind, boost::heap::mutable_ > > ::type benchmark_functor; benchmark_functor benchmark(size); double result = run_benchmark(benchmark); cout << result << '\t'; } { typedef typename benchmark_selector:: template rebind > ::type benchmark_functor; benchmark_functor benchmark(size); double result = run_benchmark(benchmark); cout << result << '\t'; } { typedef typename benchmark_selector:: template rebind > ::type benchmark_functor; benchmark_functor benchmark(size); double result = run_benchmark(benchmark); cout << result << '\t'; } { typedef typename benchmark_selector:: template rebind > ::type benchmark_functor; benchmark_functor benchmark(size); double result = run_benchmark(benchmark); cout << result << '\t'; } { typedef typename benchmark_selector:: template rebind > > ::type benchmark_functor; benchmark_functor benchmark(size); double result = run_benchmark(benchmark); cout << result << '\t'; } cout << endl; } } } int main() { cout << fixed << setprecision(12); cout << "sequential push" << endl; run_benchmarks_immutable(); cout << endl << "sequential pop" << endl; run_benchmarks_immutable(); cout << endl << "sequential increase" << endl; run_benchmarks_mutable(); cout << endl << "sequential decrease" << endl; run_benchmarks_mutable(); cout << endl << "merge_and_clear" << endl; run_benchmarks_immutable(); cout << endl << "equivalence" << endl; run_benchmarks_immutable(); }