forked from boostorg/move
- Add heap_sort and pdqsort to the benchmark.
- Refactor adaptive_sort and adaptive_merge.
This commit is contained in:
1 parent
26019b37a9
commit
e1eec15b1a
11 files changed
+1620
-1094
No files matched your search
+14
-3
@@ -36,6 +36,8 @@ void print_stats(const char *str, boost::ulong_long_type element_count)
|
||||
|
||||
#include <boost/move/algo/adaptive_sort.hpp>
|
||||
#include <boost/move/algo/detail/merge_sort.hpp>
|
||||
#include <boost/move/algo/detail/pdqsort.hpp>
|
||||
#include <boost/move/algo/detail/heap_sort.hpp>
|
||||
#include <boost/move/core.hpp>
|
||||
|
||||
template<class T>
|
||||
@@ -75,6 +77,7 @@ enum AlgoType
|
||||
{
|
||||
MergeSort,
|
||||
StableSort,
|
||||
PdQsort,
|
||||
AdaptiveSort,
|
||||
SqrtHAdaptiveSort,
|
||||
SqrtAdaptiveSort,
|
||||
@@ -88,6 +91,7 @@ enum AlgoType
|
||||
|
||||
const char *AlgoNames [] = { "MergeSort "
|
||||
, "StableSort "
|
||||
, "PdQsort "
|
||||
, "AdaptSort "
|
||||
, "SqrtHAdaptSort "
|
||||
, "SqrtAdaptSort "
|
||||
@@ -119,6 +123,9 @@ bool measure_algo(T *elements, std::size_t key_reps[], std::size_t element_count
|
||||
case StableSort:
|
||||
std::stable_sort(elements,elements+element_count,order_type_less());
|
||||
break;
|
||||
case PdQsort:
|
||||
boost::movelib::pdqsort(elements,elements+element_count,order_type_less());
|
||||
break;
|
||||
case AdaptiveSort:
|
||||
boost::movelib::adaptive_sort(elements, elements+element_count, order_type_less());
|
||||
break;
|
||||
@@ -145,8 +152,9 @@ bool measure_algo(T *elements, std::size_t key_reps[], std::size_t element_count
|
||||
boost::movelib::detail_adaptive::slow_stable_sort(elements, elements+element_count, order_type_less());
|
||||
break;
|
||||
case HeapSort:
|
||||
std::make_heap(elements, elements+element_count, order_type_less());
|
||||
std::sort_heap(elements, elements+element_count, order_type_less());
|
||||
boost::movelib::heap_sort(elements, elements+element_count, order_type_less());
|
||||
boost::movelib::heap_sort((order_move_type*)0, (order_move_type*)0, order_type_less());
|
||||
|
||||
break;
|
||||
}
|
||||
timer.stop();
|
||||
@@ -182,7 +190,7 @@ bool measure_algo(T *elements, std::size_t key_reps[], std::size_t element_count
|
||||
, units
|
||||
, prev_clock ? double(new_clock)/double(prev_clock): 1.0);
|
||||
prev_clock = new_clock;
|
||||
bool res = is_order_type_ordered(elements, element_count, alg != HeapSort);
|
||||
bool res = is_order_type_ordered(elements, element_count, alg != HeapSort && alg != PdQsort);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -205,6 +213,9 @@ bool measure_all(std::size_t L, std::size_t NK)
|
||||
res = res && measure_algo(A,Keys,L,NK,StableSort, prev_clock);
|
||||
//
|
||||
prev_clock = back_clock;
|
||||
res = res && measure_algo(A,Keys,L,NK,PdQsort, prev_clock);
|
||||
//
|
||||
prev_clock = back_clock;
|
||||
res = res && measure_algo(A,Keys,L,NK,HeapSort, prev_clock);
|
||||
//
|
||||
prev_clock = back_clock;
|
||||
|
||||
Reference in new issue
Block a user