diff --git a/bench/bench-collectionc.c b/bench/bench-collectionc.c index 4bd2aea0..85c32bbc 100644 --- a/bench/bench-collectionc.c +++ b/bench/bench-collectionc.c @@ -3,9 +3,6 @@ #include #include #include -#include -#include -#include #include "array.h" #include "slist.h" diff --git a/bench/bench-flathashmap.cpp b/bench/bench-flathashmap.cpp index f7b0705c..075b3767 100644 --- a/bench/bench-flathashmap.cpp +++ b/bench/bench-flathashmap.cpp @@ -15,9 +15,6 @@ #include #include #include -#include -#include -#include #include "flat_hash_map.hpp" diff --git a/bench/bench-glib.c b/bench/bench-glib.c index 7b049c0a..11d27721 100644 --- a/bench/bench-glib.c +++ b/bench/bench-glib.c @@ -4,9 +4,6 @@ #include #include #include -#include -#include -#include #include diff --git a/bench/bench-hopscotchmap.cpp b/bench/bench-hopscotchmap.cpp index 773be697..907054f1 100644 --- a/bench/bench-hopscotchmap.cpp +++ b/bench/bench-hopscotchmap.cpp @@ -14,9 +14,6 @@ #include #include #include -#include -#include -#include #include "src/hopscotch_map.h" diff --git a/bench/bench-klib.c b/bench/bench-klib.c index 5173c22d..51fa63e7 100644 --- a/bench/bench-klib.c +++ b/bench/bench-klib.c @@ -3,9 +3,6 @@ #include #include #include -#include -#include -#include #include "kvec.h" #include "klist.h" diff --git a/bench/bench-libdynamic.c b/bench/bench-libdynamic.c index 6f4dff39..4a91a0c6 100644 --- a/bench/bench-libdynamic.c +++ b/bench/bench-libdynamic.c @@ -5,9 +5,6 @@ #include #include #include -#include -#include -#include #include "dynamic.h" diff --git a/bench/bench-mlib.c b/bench/bench-mlib.c index 14bc5d73..8b6984af 100644 --- a/bench/bench-mlib.c +++ b/bench/bench-mlib.c @@ -3,9 +3,6 @@ #include #include #include -#include -#include -#include #include "m-array.h" #include "m-list.h" diff --git a/bench/bench-qlibc.c b/bench/bench-qlibc.c index a5c624cc..ff79c3ba 100644 --- a/bench/bench-qlibc.c +++ b/bench/bench-qlibc.c @@ -4,9 +4,6 @@ #include #include #include -#include -#include -#include #include #include "qlibc/qlibc.h" diff --git a/bench/bench-qt.cpp b/bench/bench-qt.cpp index 2523aec3..2ac74f5d 100644 --- a/bench/bench-qt.cpp +++ b/bench/bench-qt.cpp @@ -11,9 +11,6 @@ #include #include #include -#include -#include -#include using namespace std; diff --git a/bench/bench-sparsepp.cpp b/bench/bench-sparsepp.cpp index 2c49a25f..68326102 100644 --- a/bench/bench-sparsepp.cpp +++ b/bench/bench-sparsepp.cpp @@ -14,9 +14,6 @@ #include #include #include -#include -#include -#include #include diff --git a/bench/bench-stl.cpp b/bench/bench-stl.cpp index 8145691f..a34c7d09 100644 --- a/bench/bench-stl.cpp +++ b/bench/bench-stl.cpp @@ -14,9 +14,6 @@ #include #include #include -#include -#include -#include using namespace std; diff --git a/bench/bench-tommyds.c b/bench/bench-tommyds.c index 239a6bc9..b6972a6a 100644 --- a/bench/bench-tommyds.c +++ b/bench/bench-tommyds.c @@ -4,9 +4,6 @@ #include #include #include -#include -#include -#include #include "tommyds/tommy.h" diff --git a/bench/bench-uthash.c b/bench/bench-uthash.c index ece00b98..8f8faa65 100644 --- a/bench/bench-uthash.c +++ b/bench/bench-uthash.c @@ -3,9 +3,6 @@ #include #include #include -#include -#include -#include #include #include "include/uthash.h" diff --git a/bench/common.h b/bench/common.h index 35beb0ed..aed80df2 100644 --- a/bench/common.h +++ b/bench/common.h @@ -1,4 +1,48 @@ -unsigned long g_result; +/* + * M*LIB - common functions for bench module + * + * Copyright (c) 2017, Patrick Pelissier + * All rights reserved. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#ifndef __COMMON_BENCH__H +#define __COMMON_BENCH__H + +#if defined(_WIN32) +/* WINDOWS variant */ +#include + +static unsigned long long +cputime (void) +{ + LARGE_INTEGER freq, val; + QueryPerformanceFrequency(&freq); + QueryPerformanceCounter(&val); + return (unsigned long long) (1000000. * (double) val.QuadPart / (double) freq.QuadPart); +} + +#else +/* UNIX variant */ +#include +#include +#include static unsigned long long cputime (void) @@ -8,7 +52,11 @@ cputime (void) return rus.ru_utime.tv_sec * 1000000ULL + rus.ru_utime.tv_usec; } -static unsigned int randValue = 0; +#endif + +unsigned long g_result; +unsigned int randValue = 0; + static void rand_init(void) { randValue = 0; @@ -27,7 +75,7 @@ static void test_function(const char str[], size_t n, void (*func)(size_t)) (*func)(n); end = cputime(); end = (end - start) / 1000U; - printf ("%s %Lu ms for n = %lu [r=%lu]\n", str, end, n, g_result); + printf ("%s %lu ms for n = %lu [r=%lu]\n", str, (unsigned long) end, (unsigned long) n, g_result); } #if defined(_WIN32) @@ -63,3 +111,5 @@ static inline int get_cpu_count(void) return 1; #endif } + +#endif