diff --git a/bench/Makefile b/bench/Makefile index a2afeda7..e96429da 100644 --- a/bench/Makefile +++ b/bench/Makefile @@ -39,6 +39,7 @@ bench-mlib: @./bench-mlib.exe 42 @./bench-mlib.exe 43 @./bench-mlib.exe 50 + @./bench-mlib.exe 51 bench-mlib-mempool: $(CC) $(CFLAGS) $(CPPFLAGS) bench-mlib.c -DUSE_MEMPOOL -pthread -o bench-mlib-mempool.exe @@ -50,6 +51,7 @@ bench-mlib-mempool: @./bench-mlib-mempool.exe 42 @./bench-mlib-mempool.exe 43 @./bench-mlib-mempool.exe 50 + @./bench-mlib-mempool.exe 51 bench-mlib-thread: $(CC) $(CFLAGS) $(CPPFLAGS) bench-mlib.c -DMULTI_THREAD_MEASURE -pthread -o bench-mlib-thread.exe @@ -66,6 +68,7 @@ bench-stl: @./bench-stl.exe 42 @./bench-stl.exe 43 @./bench-stl.exe 50 + @./bench-stl.exe 51 # QT is supposed to be installed bench-qt: diff --git a/bench/bench-mlib.c b/bench/bench-mlib.c index 8a607c09..2a71bee4 100644 --- a/bench/bench-mlib.c +++ b/bench/bench-mlib.c @@ -263,6 +263,17 @@ static void test_sort(size_t n) } } +static void test_stable_sort(size_t n) +{ + M_LET(a1, ARRAY_OPLIST(array_float)) { + for(size_t i = 0; i < n; i++) { + array_float_push_back(a1, rand_get() ); + } + array_float_special_stable_sort(a1); + g_result = *array_float_get(a1, 0); + } +} + /********************************************************************************************/ BUFFER_DEF(buffer_uint, unsigned int, 0, BUFFER_QUEUE|BUFFER_BLOCKING) @@ -485,6 +496,8 @@ int main(int argc, const char *argv[]) test_function("DictS time", 1000000, test_dict_str); if (n == 50) test_function("Sort time", 10000000, test_sort); + if (n == 51) + test_function("Stable Sort time", 10000000, test_stable_sort); if (n == 60) test_function("Buffer time", 1000000, test_buffer); if (n == 61) diff --git a/bench/bench-stl.cpp b/bench/bench-stl.cpp index a34c7d09..ad9a0de6 100644 --- a/bench/bench-stl.cpp +++ b/bench/bench-stl.cpp @@ -208,6 +208,16 @@ static void test_sort(size_t n) g_result = a1[0]; } +static void test_stable_sort(size_t n) +{ + vector a1; + for(size_t i = 0; i < n; i++) { + a1.push_back(rand_get() ); + } + stable_sort(a1.begin(), a1.end()); + g_result = a1[0]; +} + /********************************************************************************************/ int main(int argc, const char *argv[]) @@ -231,5 +241,7 @@ int main(int argc, const char *argv[]) test_function("DictS(m) time", 1000000, test_dict_str2); if (n == 50) test_function("Sort time", 10000000, test_sort); + if (n == 51) + test_function("Stable Sort time", 10000000, test_stable_sort); exit(0); }