diff --git a/bench/Makefile b/bench/Makefile index 9f83f774..222ff9f9 100644 --- a/bench/Makefile +++ b/bench/Makefile @@ -109,7 +109,7 @@ bench-qt0: bench-glib: @if test -n "$${GLIB}" ; then $(MAKE) bench-glib0 ; else echo "Nothing to be done for GLIB." ; fi bench-glib0: - $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) bench-glib.c -o bench-glib.exe `PKG_CONFIG_PATH="$${GLIB}" pkg-config --libs --cflags glib-2.0` + $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) bench-glib.c common.c -o bench-glib.exe `PKG_CONFIG_PATH="$${GLIB}" pkg-config --libs --cflags glib-2.0` @./bench-glib.exe 10 @./bench-glib.exe 20 @./bench-glib.exe 30 @@ -122,7 +122,7 @@ bench-klib: @if test -n "$${KLIB}" ; then $(MAKE) bench-klib0 ; else echo "Nothing to be done for KLIB." ; fi bench-klib0: - $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -I $${KLIB} bench-klib.c -o bench-klib.exe + $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -I $${KLIB} bench-klib.c common.c -o bench-klib.exe @./bench-klib.exe 10 @./bench-klib.exe 20 @./bench-klib.exe 30 @@ -135,13 +135,10 @@ bench-libdynamic: @if test -n "$${LIBDYNAMIC}" ; then $(MAKE) bench-libdynamic0 ; else echo "Nothing to be done for LIBDYNAMIC." ; fi bench-libdynamic0: - $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) bench-libdynamic.c -o bench-libdynamic.exe `PKG_CONFIG_PATH="$${LIBDYNAMIC}" pkg-config --libs --cflags libdynamic` - @./bench-libdynamic.exe 10 + $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) bench-libdynamic.c common.c -o bench-libdynamic.exe `PKG_CONFIG_PATH="$${LIBDYNAMIC}" pkg-config --libs --cflags libdynamic` @./bench-libdynamic.exe 20 - @./bench-libdynamic.exe 30 @./bench-libdynamic.exe 40 @./bench-libdynamic.exe 41 - @./bench-libdynamic.exe 50 # SPARSEPP shall point to the directory where the headers are bench-sparsepp: @@ -168,7 +165,7 @@ bench-collectionc: @if test -n "$${COLLECTIONC}" ; then $(MAKE) bench-collectionc0 ; else echo "Nothing to be done for COLLECTIONC." ; fi bench-collectionc0: - $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -I "$${COLLECTIONC}/include" -L "$${COLLECTIONC}" -static bench-collectionc.c -lcollectc -o bench-collectionc.exe + $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -I "$${COLLECTIONC}/include" -L "$${COLLECTIONC}" -static bench-collectionc.c common.c -lcollectc -o bench-collectionc.exe @./bench-collectionc.exe 10 @./bench-collectionc.exe 20 @./bench-collectionc.exe 30 @@ -181,7 +178,7 @@ bench-tommyds: @if test -n "$${TOMMYDS}" ; then $(MAKE) bench-tommyds0 ; else echo "Nothing to be done for TOMMYDS." ; fi bench-tommyds0: - $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -I "$${TOMMYDS}" bench-tommyds.c $${TOMMYDS}/tommyds/tommyarray.c $${TOMMYDS}/tommyds/tommylist.c $${TOMMYDS}/tommyds/tommytree.c $${TOMMYDS}/tommyds/tommyhashlin.c -o bench-tommyds.exe + $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -I "$${TOMMYDS}" bench-tommyds.c $${TOMMYDS}/tommyds/tommyarray.c $${TOMMYDS}/tommyds/tommylist.c $${TOMMYDS}/tommyds/tommytree.c $${TOMMYDS}/tommyds/tommyhashlin.c common.c -o bench-tommyds.exe @./bench-tommyds.exe 10 @./bench-tommyds.exe 20 @./bench-tommyds.exe 30 @@ -214,7 +211,7 @@ bench-uthash: @if test -n "$${UTHASH}" ; then $(MAKE) bench-uthash0 ; else echo "Nothing to be done for UTHASH." ; fi bench-uthash0: - $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -I "$${UTHASH}" bench-uthash.c -o bench-uthash.exe + $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -I "$${UTHASH}" bench-uthash.c common.c -o bench-uthash.exe @./bench-uthash.exe 10 @./bench-uthash.exe 20 @./bench-uthash.exe 41 @@ -227,7 +224,7 @@ bench-qlibc: @if test -n "$${QLIBC}" ; then $(MAKE) bench-qlibc0 ; else echo "Nothing to be done for QLIBC." ; fi bench-qlibc0: - $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -I "$${QLIBC}/include" -L "$${QLIBC}/lib" -lqlibc -pthread bench-qlibc.c -o bench-qlibc.exe + $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -I "$${QLIBC}/include" -L "$${QLIBC}/lib" -lqlibc -pthread bench-qlibc.c common.c -o bench-qlibc.exe @LD_LIBRARY_PATH="$${QLIBC}/lib:$${LD_LIBRARY_PATH}" ./bench-qlibc.exe 10 @LD_LIBRARY_PATH="$${QLIBC}/lib:$${LD_LIBRARY_PATH}" ./bench-qlibc.exe 20 @LD_LIBRARY_PATH="$${QLIBC}/lib:$${LD_LIBRARY_PATH}" ./bench-qlibc.exe 30 @@ -240,7 +237,7 @@ bench-libsrt: @if test -n "$${LIBSRT}" ; then $(MAKE) bench-libsrt0 ; else echo "Nothing to be done for LIBSRT." ; fi bench-libsrt0: - $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -I "$${LIBSRT}/src" bench-libsrt.c -o bench-libsrt.exe $${LIBSRT}/libsrt.a + $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -I "$${LIBSRT}/src" bench-libsrt.c common.c -o bench-libsrt.exe $${LIBSRT}/libsrt.a @./bench-libsrt.exe 10 @./bench-libsrt.exe 20 @./bench-libsrt.exe 41 @@ -254,7 +251,7 @@ bench-libsrt0: bench-liblfds: @if test -n "$${LIBLFDS}" ; then $(MAKE) bench-liblfds0 ; else echo "Nothing to be done for LIBLFDS." ; fi bench-liblfds0: - $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -I "$${LIBLFDS}/inc" -Wno-unknown-pragmas bench-liblfds.c -o bench-liblfds.exe $${LIBLFDS}/bin/liblfds711.a -lpthread + $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -I "$${LIBLFDS}/inc" -Wno-unknown-pragmas bench-liblfds.c common.c -o bench-liblfds.exe $${LIBLFDS}/bin/liblfds711.a -lpthread @LD_LIBRARY_PATH="$${LIBLFDS}/bin:$${LD_LIBRARY_PATH}" ./bench-liblfds.exe 60 @@ -272,7 +269,7 @@ bench-concurrentqueue0: bench-xxhash: @if test -n "$${XXHASH}" ; then $(MAKE) bench-xxhash0 ; else echo "Nothing to be done for XXHASH." ; fi bench-xxhash0: - $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -I "$${XXHASH}/" bench-xxhash.c "$${XXHASH}/libxxhash.a" -o bench-xxhash.exe + $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -I "$${XXHASH}/" bench-xxhash.c common.c "$${XXHASH}/libxxhash.a" -o bench-xxhash.exe @./bench-xxhash.exe 70 # BOOST shall point to the header location. @@ -286,7 +283,7 @@ bench-boost0: bench-nedtries: @if test -n "$${NEDTRIES}" ; then $(MAKE) bench-nedtries0 ; else echo "Nothing to be done for NEDTRIES." ; fi bench-nedtries0: - $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -I "$${NEDTRIES}" bench-nedtries.c -o bench-nedtries.exe + $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -I "$${NEDTRIES}" bench-nedtries.c common.c -o bench-nedtries.exe @./bench-nedtries.exe 40 @./bench-nedtries.exe 45 diff --git a/bench/bench-boost.cpp b/bench/bench-boost.cpp index 5592cf8c..36e5133c 100644 --- a/bench/bench-boost.cpp +++ b/bench/bench-boost.cpp @@ -92,7 +92,7 @@ int main(int argc, const char *argv[]) { int n = (argc > 1) ? atoi(argv[1]) : 0; if (n == 60) - test_function("QueueMPMC", 1000000, test_queue); + test_function("Queue MPMC", 1000000, test_queue); exit(0); } diff --git a/bench/bench-collectionc.c b/bench/bench-collectionc.c index 88f8d0e4..72be13e7 100644 --- a/bench/bench-collectionc.c +++ b/bench/bench-collectionc.c @@ -250,20 +250,17 @@ static void test_sort(size_t n) /********************************************************************************************/ +const config_func_t table[] = { + { 10, "List", 10000000, 0, test_list, 0}, + { 20, "Array", 100000000, 0, test_array, 0}, + { 30, "Rbtree", 1000000, 0, test_rbtree, 0}, + { 40, "dict", 1000000, 0, test_dict, 0}, + { 41, "dictBig", 1000000, 0, test_dict_big, 0}, + { 50, "Sort",10000000, 0, test_sort, 0}, +}; + int main(int argc, const char *argv[]) { - int n = (argc > 1) ? atoi(argv[1]) : 0; - if (n == 10) - test_function("List",10000000, test_list); - if (n == 20) - test_function("Array", 100000000, test_array); - if (n == 30) - test_function("Rbtree", 1000000, test_rbtree); - if (n == 40) - test_function("Dict", 1000000, test_dict); - if (n == 41) - test_function("DictBig", 1000000, test_dict_big); - if (n == 50) - test_function("Sort", 10000000, test_sort); + test("CollectionC", numberof(table), table, argc, argv); exit(0); } diff --git a/bench/bench-glib.c b/bench/bench-glib.c index 9699b6e8..32414eb7 100644 --- a/bench/bench-glib.c +++ b/bench/bench-glib.c @@ -186,20 +186,17 @@ static void test_sort(size_t n) /********************************************************************************************/ +const config_func_t table[] = { + { 10, "List", 10000000, 0, test_list, 0}, + { 20, "Array", 100000000, 0, test_array, 0}, + { 30, "Rbtree", 1000000, 0, test_rbtree, 0}, + { 40, "dict", 1000000, 0, test_dict, 0}, + { 41, "dictBig", 1000000, 0, test_dict_big, 0}, + { 50, "Sort",10000000, 0, test_sort, 0}, +}; + int main(int argc, const char *argv[]) { - int n = (argc > 1) ? atoi(argv[1]) : 0; - if (n == 10) - test_function("List",10000000, test_list); - if (n == 20) - test_function("Array", 100000000, test_array); - if (n == 30) - test_function("Rbtree", 1000000, test_rbtree); - if (n == 40) - test_function("Dict", 1000000, test_dict); - if (n == 41) - test_function("DictBig", 1000000, test_dict_big); - if (n == 50) - test_function("Sort", 10000000, test_sort); + test("GLIB", numberof(table), table, argc, argv); exit(0); } diff --git a/bench/bench-klib.c b/bench/bench-klib.c index 3139dea4..13a90dcd 100644 --- a/bench/bench-klib.c +++ b/bench/bench-klib.c @@ -185,21 +185,18 @@ static void test_sort(size_t n) /********************************************************************************************/ +const config_func_t table[] = { + { 10, "List", 10000000, 0, test_list, 0}, + { 20, "Array", 100000000, 0, test_array, 0}, + { 30, "Rbtree", 1000000, 0, test_rbtree, 0}, + { 40, "dict", 1000000, 0, test_dict, 0}, + { 41, "dictBig", 1000000, 0, test_dict_big, 0}, + { 50, "Sort",10000000, 0, test_sort, 0}, +}; + int main(int argc, const char *argv[]) { - int n = (argc > 1) ? atoi(argv[1]): 0; - if (n == 10) - test_function("List",10000000, test_list); - if (n == 20) - test_function("Array", 100000000, test_array); - if (n == 30) - test_function("B-tree", 1000000, test_rbtree); - if (n == 40) - test_function("Dict", 1000000, test_dict); - if (n == 41) - test_function("DictBig", 1000000, test_dict_big); - if (n == 50) - test_function("Sort", 10000000, test_sort); + test("KLIB", numberof(table), table, argc, argv); exit(0); } diff --git a/bench/bench-libdynamic.c b/bench/bench-libdynamic.c index 02a387e8..c6013a5b 100644 --- a/bench/bench-libdynamic.c +++ b/bench/bench-libdynamic.c @@ -144,14 +144,14 @@ test_dict_big(size_t n) /********************************************************************************************/ +const config_func_t table[] = { + { 20, "Array", 100000000, 0, test_array, 0}, + { 40, "dict", 1000000, 0, test_dict, 0}, + { 41, "dictBig", 1000000, 0, test_dict_big, 0}, +}; + int main(int argc, const char *argv[]) { - int n = (argc > 1) ? atoi(argv[1]) : 0; - if (n == 20) - test_function("Array", 100000000, test_array); - if (n == 40) - test_function("Dict", 1000000, test_dict); - if (n == 41) - test_function("DictBig", 1000000, test_dict_big); + test("LIBDYNAMIC", numberof(table), table, argc, argv); exit(0); } diff --git a/bench/bench-liblfds.c b/bench/bench-liblfds.c index 0db29dfc..411b74a3 100644 --- a/bench/bench-liblfds.c +++ b/bench/bench-liblfds.c @@ -6,11 +6,9 @@ #include "liblfds711.h" -#include "m-mutex.h" #define MULTI_THREAD_MEASURE #include "common.h" - /********************************************************************************************/ struct lfds711_queue_bmm_state g_buff; @@ -23,12 +21,9 @@ static void final(void *arg) unsigned long long j, s = 0; LFDS711_MISC_MAKE_VALID_ON_CURRENT_LOGICAL_CORE_INITS_COMPLETED_BEFORE_NOW_ON_ANY_OTHER_LOGICAL_CORE; for(int i = 0; i < n;i++) { - int rv; - do { - void *p; - rv = lfds711_queue_bmm_dequeue(&g_final, &p, NULL); - j = (uintptr_t)p; - } while (rv == 0); + void *p; + while (0 == lfds711_queue_bmm_dequeue(&g_final, &p, NULL)) { m_thread_yield(); } + j = (uintptr_t)p; s += j; } g_result = s; @@ -42,18 +37,12 @@ static void conso(void *arg) unsigned long long s = 0; LFDS711_MISC_MAKE_VALID_ON_CURRENT_LOGICAL_CORE_INITS_COMPLETED_BEFORE_NOW_ON_ANY_OTHER_LOGICAL_CORE; for(int i = 0; i < n;i++) { - int rv; - do { - void *p; - rv = lfds711_queue_bmm_dequeue(&g_buff, &p, NULL); - j = (uintptr_t) p; - } while (rv == 0); + void *p; + while (0 == lfds711_queue_bmm_dequeue(&g_buff, &p, NULL)) { m_thread_yield(); } + j = (uintptr_t) p; s += j; } - int rv; - do { - rv = lfds711_queue_bmm_enqueue(&g_final, (void*)(uintptr_t)s, NULL); - } while (rv == 0); + while (0 == lfds711_queue_bmm_enqueue(&g_final, (void*)(uintptr_t)s, NULL)) { m_thread_yield(); } } static void prod(void *arg) @@ -63,15 +52,12 @@ static void prod(void *arg) size_t r = n; LFDS711_MISC_MAKE_VALID_ON_CURRENT_LOGICAL_CORE_INITS_COMPLETED_BEFORE_NOW_ON_ANY_OTHER_LOGICAL_CORE; for(unsigned int i = 0; i < n;i++) { - int rv; - do { - rv = lfds711_queue_bmm_enqueue(&g_buff, (void*)(uintptr_t)r, NULL); - } while (rv == 0); + while (0 == lfds711_queue_bmm_enqueue(&g_buff, (void*)(uintptr_t)r, NULL)) { m_thread_yield(); } r = r * 31421U + 6927U; } } -static void test_buffer(size_t n) +static void test_queue(size_t n) { const int cpu_count = get_cpu_count(); const int prod_count = cpu_count/2; @@ -120,11 +106,12 @@ static void test_buffer(size_t n) /********************************************************************************************/ +const config_func_t table[] = { + { 60, "Queue MPMC", 1000000, 0, test_queue, 0} +}; + int main(int argc, const char *argv[]) { - int n = (argc > 1) ? atoi(argv[1]) : 0; - if (n == 60) - test_function("Buffer", 1000000, test_buffer); + test("LIBLFDS", numberof(table), table, argc, argv); exit(0); } - diff --git a/bench/bench-libsrt.c b/bench/bench-libsrt.c index e731fe6f..e65de678 100644 --- a/bench/bench-libsrt.c +++ b/bench/bench-libsrt.c @@ -60,6 +60,18 @@ static void test_sort(size_t n) /********************************************************************************************/ + +const config_func_t table[] = { + { 20, "Array", 100000000, 0, test_array, 0}, + { 50, "sort", 10000000, 0, test_sort, 0} +}; + +int main(int argc, const char *argv[]) +{ + test("LIBSRT", numberof(table), table, argc, argv); + exit(0); +} + int main(int argc, const char *argv[]) { int n = (argc > 1) ? atoi(argv[1]) : 0; diff --git a/bench/bench-mlib.c b/bench/bench-mlib.c index f82318b7..3e934505 100644 --- a/bench/bench-mlib.c +++ b/bench/bench-mlib.c @@ -862,12 +862,10 @@ const config_func_t table[] = { { 66,"Queue SPSC(Bulk)", 1000000, 0, test_queue_single_bulk, 0}, { 70,"M_HASH", 100000000, test_hash_prepare, test_hash, test_hash_final}, { 71,"Core Hash", 100000000, test_hash_prepare, test_core_hash, test_hash_final} -} -; +}; int main(int argc, const char *argv[]) { test("M-LIB", numberof(table), table, argc, argv); exit(0); } - diff --git a/bench/bench-nedtries.c b/bench/bench-nedtries.c index 7f52f49f..5024ec7f 100644 --- a/bench/bench-nedtries.c +++ b/bench/bench-nedtries.c @@ -87,15 +87,13 @@ test_dict_noalloc(size_t n) /********************************************************************************************/ +const config_func_t table[] = { + { 40, "dict", 1000000, 0, test_dict, 0}, + { 45, "dict(noalloc)", 1000000, 0, test_dict_noalloc, 0} +}; int main(int argc, const char *argv[]) { - int n = (argc > 1) ? atoi(argv[1]) : 0; - if (n == 40) - test_function("Dict", 1000000, test_dict); - if (n == 45) - test_function("Dict(NoAlloc)", 1000000, test_dict_noalloc); - + test("NEDTRIES", numberof(table), table, argc, argv); exit(0); } - diff --git a/bench/bench-qlibc.c b/bench/bench-qlibc.c index 39721af7..c5f73c3e 100644 --- a/bench/bench-qlibc.c +++ b/bench/bench-qlibc.c @@ -98,14 +98,16 @@ static void test_rbtree(size_t n) /* qlibc hash functions only accept a string as the key */ +/********************************************************************************************/ + +const config_func_t table[] = { + { 10, "List", 10000000, 0, test_list, 0}, + { 20, "Array", 100000000, 0, test_array, 0}, + { 30, "Rbtree", 1000000, 0, test_rbtree, 0} +}; + int main(int argc, const char *argv[]) { - int n = (argc > 1) ? atoi(argv[1]) : 0; - if (n == 20) - test_function("Array time", 100000000, test_array); - if (n == 10) - test_function("List time",10000000, test_list); - if (n == 30) - test_function("Rbtree time", 1000000, test_rbtree); + test("QLIBC", numberof(table), table, argc, argv); exit(0); } diff --git a/bench/bench-tommyds.c b/bench/bench-tommyds.c index dfd7ccc8..411899ab 100644 --- a/bench/bench-tommyds.c +++ b/bench/bench-tommyds.c @@ -206,18 +206,16 @@ test_dict_big(size_t n) /********************************************************************************************/ +const config_func_t table[] = { + { 10, "List", 10000000, 0, test_list, 0}, + { 20, "Array", 100000000, 0, test_array, 0}, + { 30, "Rbtree", 1000000, 0, test_rbtree, 0}, + { 40, "dict", 1000000, 0, test_dict, 0}, + { 41, "dictBig", 1000000, 0, test_dict_big, 0} +}; + int main(int argc, const char *argv[]) { - int n = (argc > 1) ? atoi(argv[1]) : 0; - if (n == 10) - test_function("List",10000000, test_list); - if (n == 20) - test_function("Array", 100000000, test_array); - if (n == 30) - test_function("Rbtree", 1000000, test_rbtree); - if (n == 40) - test_function("Dict", 1000000, test_dict); - if (n == 41) - test_function("DictBig", 1000000, test_dict_big); + test("TommyDS", numberof(table), table, argc, argv); exit(0); } diff --git a/bench/bench-uthash.c b/bench/bench-uthash.c index faa70c60..2678b823 100644 --- a/bench/bench-uthash.c +++ b/bench/bench-uthash.c @@ -199,19 +199,17 @@ static void test_sort(size_t n) /********************************************************************************************/ +const config_func_t table[] = { + { 10, "List", 10000000, 0, test_list, 0}, + { 20, "Array", 100000000, 0, test_array, 0}, + { 30, "Rbtree", 1000000, 0, test_rbtree, 0}, + { 40, "dict", 1000000, 0, test_dict, 0}, + { 41, "dictBig", 1000000, 0, test_dict_big, 0} + { 50, "sort", 10000000, 0, test_sort, 0} +}; + int main(int argc, const char *argv[]) { - int n = (argc > 1) ? atoi(argv[1]): 0; - if (n == 10) - test_function("List time",10000000, test_list); - if (n == 20) - test_function("Array time", 100000000, test_array); - if (n == 40 || n == 42) - test_function("Dict time", 1000000, test_dict); - if (n == 41) - test_function("DictB time", 1000000, test_dict_big); - if (n == 50) - test_function("Sort time", 10000000, test_sort); + test("UT-HASH", numberof(table), table, argc, argv); exit(0); } - diff --git a/bench/bench-xxhash.c b/bench/bench-xxhash.c index 5c154383..d4c598b7 100644 --- a/bench/bench-xxhash.c +++ b/bench/bench-xxhash.c @@ -31,17 +31,12 @@ static void test_hash(size_t n) /********************************************************************************************/ +const config_func_t table[] = { + { 70,"XXHASH64", 100000000, test_hash_prepare, test_hash, test_hash_final} +}; int main(int argc, const char *argv[]) { - int n = (argc > 1) ? atoi(argv[1]) : 0; - if (n == 70) { - n = (argc > 2) ? atoi(argv[2]) : 100000000; - test_hash_prepare(n); - test_function("XXHASH64", n, test_hash); - test_hash_final(); - } - + test("XXHASH", numberof(table), table, argc, argv); exit(0); } -