Add benchmark udb2.
This commit is contained in:
1 parent
7b11f5afbc
commit
fae899e52e
3 files changed
+87
No files matched your search
@@ -0,0 +1,33 @@
|
|||||||
|
CC= gcc
|
||||||
|
CXX= g++
|
||||||
|
CFLAGS= -g -Wall -O2 -fomit-frame-pointer -march=native -lm -include stddef.h
|
||||||
|
CXXFLAGS= $(CFLAGS)
|
||||||
|
LDFLAGS=
|
||||||
|
OBJS=
|
||||||
|
LIBS=
|
||||||
|
|
||||||
|
all: run
|
||||||
|
|
||||||
|
udb2:
|
||||||
|
git clone https://github.com/attractivechaos/udb2.git
|
||||||
|
|
||||||
|
build: udb2
|
||||||
|
mkdir -p udb2/mlib
|
||||||
|
cp test-mlib.c udb2/mlib/test.c
|
||||||
|
cp Makefile-mlib udb2/mlib/Makefile
|
||||||
|
touch build
|
||||||
|
|
||||||
|
all-recur: build
|
||||||
|
cd udb2/stb && make CC="gcc -lm"
|
||||||
|
cd udb2 && for dir in `ls | egrep -v '^(Makefile|common.c|_)'`; do cd $$dir && make && cd -; done
|
||||||
|
|
||||||
|
run: all-recur
|
||||||
|
@cd udb2; \
|
||||||
|
echo ; echo RUNNING BENCH ; echo ; \
|
||||||
|
for i in `find . -name 'run-test'` ; do \
|
||||||
|
echo ; echo `dirname $$i|sed -e 's+./++g'`; \
|
||||||
|
$$i ; \
|
||||||
|
done
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf udb2 build *~
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
all:run-test
|
||||||
|
|
||||||
|
run-test:test.c ../common.c
|
||||||
|
$(CC) -std=gnu99 -O2 -Wall -I../../../.. $< -o $@
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f run-test* *~
|
||||||
|
rm -rf mlib
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
/* Makefile:
|
||||||
|
|
||||||
|
all:run-test
|
||||||
|
|
||||||
|
run-test:test.c ../common.c mlib
|
||||||
|
$(CC) -std=gnu99 -O2 -Wall -Imlib $< -o $@
|
||||||
|
|
||||||
|
mlib:
|
||||||
|
git clone https://github.com/P-p-H-d/mlib.git
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f run-test* *~
|
||||||
|
rm -rf mlib
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "../common.c"
|
||||||
|
#include "m-dict.h"
|
||||||
|
|
||||||
|
static inline bool oor_equal_p(unsigned int k, unsigned char n)
|
||||||
|
{
|
||||||
|
return k == (unsigned int)n;
|
||||||
|
}
|
||||||
|
static inline void oor_set(unsigned int *k, unsigned char n)
|
||||||
|
{
|
||||||
|
*k = (unsigned int)n;
|
||||||
|
}
|
||||||
|
|
||||||
|
DICT_OA_DEF2(dict_oa_uint,
|
||||||
|
unsigned int, M_OPEXTEND(M_DEFAULT_OPLIST, OOR_EQUAL(oor_equal_p), OOR_SET(oor_set M_IPTR)),
|
||||||
|
unsigned int, M_DEFAULT_OPLIST)
|
||||||
|
|
||||||
|
void test_int(uint32_t n, uint32_t x0)
|
||||||
|
{
|
||||||
|
uint32_t i, x, z = 0;
|
||||||
|
dict_oa_uint_t h;
|
||||||
|
dict_oa_uint_init(h);
|
||||||
|
for (i = 0, x = x0; i < n; ++i) {
|
||||||
|
x = hash32(x);
|
||||||
|
unsigned int key = get_key(n, x);
|
||||||
|
unsigned int *ptr = dict_oa_uint_get(h, key);
|
||||||
|
if (ptr) (*ptr)++;
|
||||||
|
else dict_oa_uint_set_at(h, key, 1);
|
||||||
|
}
|
||||||
|
fprintf(stderr, "# unique keys: %d; checksum: %u\n", (int) dict_oa_uint_size(h), z);
|
||||||
|
dict_oa_uint_clear(h);
|
||||||
|
}
|
||||||
Reference in new issue
Block a user