Add bench of hash computation library (XXHASH)
This commit is contained in:
1 parent
557dd3e0d5
commit
992bb6a73a
2 files changed
+55
No files matched your search
@@ -238,6 +238,14 @@ bench-concurrentqueue0:
|
|||||||
@./bench-concurrentqueue.exe 60
|
@./bench-concurrentqueue.exe 60
|
||||||
|
|
||||||
|
|
||||||
|
# XXHASH shall point to the source directory of xxhash
|
||||||
|
bench-xxhash:
|
||||||
|
@if test -n "$${XXHASH}" ; then $(MAKE) bench-xxhash0 ; else echo "Nothing to be done for XXHASH." ; fi
|
||||||
|
|
||||||
|
bench-xxhash0:
|
||||||
|
$(CC) $(CFLAGS) $(CPPFLAGS) -I "$${XXHASH}/" bench-xxhash.c "$${XXHASH}/libxxhash.a" -o bench-xxhash.exe
|
||||||
|
@./bench-xxhash.exe 70
|
||||||
|
|
||||||
# BOOST is assumed to be installed in the system
|
# BOOST is assumed to be installed in the system
|
||||||
bench-boost:
|
bench-boost:
|
||||||
$(CXX) $(CFLAGS) $(CPPFLAGS) bench-boost.cpp -o bench-boost.exe -lpthread
|
$(CXX) $(CFLAGS) $(CPPFLAGS) bench-boost.cpp -o bench-boost.exe -lpthread
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
#define NDEBUG
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include "xxhash.h"
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
static unsigned long *g_p;
|
||||||
|
|
||||||
|
static void test_hash_prepare(size_t n)
|
||||||
|
{
|
||||||
|
g_p = malloc (n * sizeof(unsigned long));
|
||||||
|
if (g_p == NULL) abort();
|
||||||
|
for(size_t i = 0; i < n ; i++)
|
||||||
|
g_p[i] = ((rand_get()*RAND_MAX + rand_get())*RAND_MAX+rand_get())*RAND_MAX + rand_get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void test_hash_final(void)
|
||||||
|
{
|
||||||
|
free(g_p);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_hash(size_t n)
|
||||||
|
{
|
||||||
|
g_result = XXH64(g_p, sizeof(unsigned long)*n, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/********************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
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 time", n, test_hash);
|
||||||
|
test_hash_final();
|
||||||
|
}
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
Reference in new issue
Block a user