tweak: added ska_sort for measuring against because Ypsu told me about it... mixed results on my machine (on small numbers below 100 mine wins always, above it is really mixed and close)
This commit is contained in:
parent
860cc4e702
commit
76ba29018d
9
makefile
9
makefile
@ -4,5 +4,14 @@ debug: test.cpp magyarsort.h
|
|||||||
release: test.cpp magyarsort.h
|
release: test.cpp magyarsort.h
|
||||||
g++ test.cpp -std=c++14 -O2 -o test.out
|
g++ test.cpp -std=c++14 -O2 -o test.out
|
||||||
|
|
||||||
|
release3: test.cpp magyarsort.h
|
||||||
|
g++ test.cpp -std=c++14 -O3 -o test.out
|
||||||
|
|
||||||
|
clang_release: test.cpp magyarsort.h
|
||||||
|
clang++ test.cpp -std=c++14 -O2 -o test.out
|
||||||
|
|
||||||
|
clang_release3: test.cpp magyarsort.h
|
||||||
|
clang++ test.cpp -std=c++14 -O3 -o test.out
|
||||||
|
|
||||||
clean: test.out
|
clean: test.out
|
||||||
rm test.out
|
rm test.out
|
||||||
|
|||||||
1445
ska_sort.hpp
Normal file
1445
ska_sort.hpp
Normal file
File diff suppressed because it is too large
Load Diff
16
test.cpp
16
test.cpp
@ -6,6 +6,7 @@
|
|||||||
// #define CREEL // Overwrites TEST_LEN to 16 and sets MAGYAR_SORT_NIBBLE!
|
// #define CREEL // Overwrites TEST_LEN to 16 and sets MAGYAR_SORT_NIBBLE!
|
||||||
|
|
||||||
// Number of input elements to generate - unused when CREEL is defined!
|
// Number of input elements to generate - unused when CREEL is defined!
|
||||||
|
//#define SORT_WIDTH 200000000
|
||||||
#define SORT_WIDTH 40000
|
#define SORT_WIDTH 40000
|
||||||
// Uncomment this to use nibbles as digits and not bytes - CREEL defines this anyways
|
// Uncomment this to use nibbles as digits and not bytes - CREEL defines this anyways
|
||||||
//#define MAGYAR_SORT_NIBBLE
|
//#define MAGYAR_SORT_NIBBLE
|
||||||
@ -13,6 +14,8 @@
|
|||||||
// Uncomment if you want to see output before / after sorts (debugging for example)
|
// Uncomment if you want to see output before / after sorts (debugging for example)
|
||||||
//#define PRINT_OUTPUT
|
//#define PRINT_OUTPUT
|
||||||
|
|
||||||
|
//#define SKA_SORT
|
||||||
|
|
||||||
/* Includes */
|
/* Includes */
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@ -24,6 +27,10 @@
|
|||||||
#include <algorithm> // std::sort
|
#include <algorithm> // std::sort
|
||||||
#include "magyarsort.h"
|
#include "magyarsort.h"
|
||||||
|
|
||||||
|
#ifdef SKA_SORT
|
||||||
|
#include "ska_sort.hpp"
|
||||||
|
#endif // SKA_SORT
|
||||||
|
|
||||||
/* Input generation and prerequisites */
|
/* Input generation and prerequisites */
|
||||||
|
|
||||||
#ifdef CREEL
|
#ifdef CREEL
|
||||||
@ -97,9 +104,16 @@ int main() {
|
|||||||
MagyarSort::debugArr(arr1, in1.size());
|
MagyarSort::debugArr(arr1, in1.size());
|
||||||
#endif // PRINT_OUTPUT
|
#endif // PRINT_OUTPUT
|
||||||
|
|
||||||
/* std::sort */
|
|
||||||
auto stdBegin = std::chrono::high_resolution_clock::now();
|
auto stdBegin = std::chrono::high_resolution_clock::now();
|
||||||
|
#ifndef SKA_SORT
|
||||||
|
/* std::sort */
|
||||||
std::sort(std::begin(in2), std::end(in2));
|
std::sort(std::begin(in2), std::end(in2));
|
||||||
|
#else // SKA_SORT
|
||||||
|
/* Ska-sort */
|
||||||
|
//ska_sort(std::begin(in2), std::end(in2));
|
||||||
|
std::vector<uint32_t> buffer(in2.size());
|
||||||
|
if (ska_sort_copy(std::begin(in2), std::end(in2), std::begin(buffer))) in2.swap(buffer);
|
||||||
|
#endif // SKA_SORT
|
||||||
auto stdEnd = std::chrono::high_resolution_clock::now();
|
auto stdEnd = std::chrono::high_resolution_clock::now();
|
||||||
|
|
||||||
#ifdef PRINT_OUTPUT
|
#ifdef PRINT_OUTPUT
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user