diff --git a/.travis.yml b/.travis.yml index e4b4774..56b6e1c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,9 @@ matrix: - compiler: gcc env: CONFIGURE_OPTION='--enable-debug --with-malloc=jemalloc' COVERALLS=yes VALGRIND=no - compiler: gcc - env: CONFIGURE_OPTION='--enable-debug --with-malloc=jemalloc' COVERALLS=yes VALGRIND=yes LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/ + env: CONFIGURE_OPTION='--enable-debug' COVERALLS=yes VALGRIND=yes LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/ + - compiler: clang + env: ASAN_OPTIONS=symbolize=1 ASAN_SYMBOLIZER_PATH=/usr/local/clang-3.4/bin/llvm-symbolizer CFLAGS='-fsanitize=address -g -O1' install: - sudo apt-get update -qq @@ -23,9 +25,9 @@ before_script: script: - ./autogen.sh - ./configure $CONFIGURE_OPTION - - make + - make V=1 - sudo make install - - if [ "x$VALGRIND" == xyes ]; then make check > /dev/null 2>&1; else make check; fi + - if [ "x$VALGRIND" == xyes ]; then make check > /dev/null 2>&1; else make check V=1; fi - if [ "x$VALGRIND" == xyes ]; then valgrind ./tests/.libs/* -v --trace-children=yes --show-leak-kinds=full --leak-check=full; fi after_success: diff --git a/bench.html b/bench.html index d395786..c0a3de5 100644 --- a/bench.html +++ b/bench.html @@ -60,11 +60,13 @@ }], legend: { - align: 'left', + align: 'right', verticalAlign: 'top', - y: 20, - floating: true, - borderWidth: 0 + y: 50, + floating: false, + layout: 'vertical', + background: '#fff', + borderWidth: 1, }, tooltip: { @@ -73,6 +75,7 @@ }, plotOptions: { + /* area: { fillColor: { linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1}, @@ -92,28 +95,58 @@ }, threshold: null } + */ }, - series: [{ - type: 'area', - name: 'Speed', - pointInterval: 1000, - lineWidth: 2, - marker: { - radius: 3 + series: [ + { + type: 'area', + name: 'string matching', + pointInterval: 1000, + lineWidth: 1, + marker: { + radius: 3 + }, + pointStart: Date.UTC(2014, 5, 16), + data: [] }, - pointStart: Date.UTC(2014, 5, 16), - data: [] - }] + { + type: 'area', + name: '/post/{year}/{month}', + pointInterval: 1000, + lineWidth: 1, + marker: { + radius: 3 + }, + pointStart: Date.UTC(2014, 5, 16), + data: [] + }, + { + type: 'area', + name: 'tree_compile', + pointInterval: 1000, + lineWidth: 1, + marker: { + radius: 3 + }, + pointStart: Date.UTC(2014, 5, 16), + data: [] + } + ] }; var lines = data.split(/\n/); $(lines).each(function(i,line) { var columns = line.split(/,/); - var i = parseInt(columns[1]); - if(i) { - options.series[0].data.push(i); - } + var a; + a = parseInt(columns[1]); + options.series[0].data.push(a || 0); + + a = parseInt(columns[2]); + options.series[1].data.push(a || 0); + + a = parseInt(columns[3]); + options.series[2].data.push(a || 0); }); $('#chart').highcharts(options); diff --git a/config.h b/config.h index 1c2d1b7..4eea962 100644 --- a/config.h +++ b/config.h @@ -3,9 +3,12 @@ /* "whether graphviz is enable" */ #define ENABLE_GRAPHVIZ test "x$enable_graphviz" = "xyes" +<<<<<<< HEAD /* "whether statistics is enable" */ #define ENABLE_STATS test "x$enable_stats" = "xyes" +======= +>>>>>>> master /* Define to 1 if you have the header file. */ #define HAVE_DLFCN_H 1 diff --git a/include/r3.h b/include/r3.h index 6a3db24..6de7edf 100644 --- a/include/r3.h +++ b/include/r3.h @@ -4,9 +4,8 @@ * * Distributed under terms of the MIT license. */ - -#ifndef NODE_H -#define NODE_H +#ifndef R3_NODE_H +#define R3_NODE_H #include #include @@ -194,4 +193,4 @@ void r3_tree_feedback(node *tree, node *end); #define METHOD_PUT 2<<1 #define METHOD_DELETE 2<<1 -#endif /* !NODE_H */ +#endif /* !R3_NODE_H */ diff --git a/include/r3_list.h b/include/r3_list.h index 96e878c..bd231ef 100644 --- a/include/r3_list.h +++ b/include/r3_list.h @@ -5,8 +5,8 @@ * Distributed under terms of the MIT license. */ -#ifndef LIST_H -#define LIST_H +#ifndef R3_LIST_H +#define R3_LIST_H #include @@ -32,4 +32,4 @@ void list_each_element(list *l, int (*func)(list_item *)); -#endif /* !LIST_H */ +#endif /* !R3_LIST_H */ diff --git a/src/node.c b/src/node.c index ea47095..7996806 100644 --- a/src/node.c +++ b/src/node.c @@ -268,10 +268,8 @@ match_entry * match_entry_createl(char * path, int path_len) { } void match_entry_free(match_entry * entry) { - if (entry) { - str_array_free(entry->vars); - zfree(entry); - } + str_array_free(entry->vars); + zfree(entry); } @@ -420,9 +418,7 @@ route * r3_route_create(char * path) { } void r3_route_free(route * route) { - if (route) { - zfree(route); - } + zfree(route); } route * r3_route_createl(char * path, int path_len) { diff --git a/src/token.c b/src/token.c index 5c00e2e..e0f23a8 100644 --- a/src/token.c +++ b/src/token.c @@ -23,9 +23,7 @@ str_array * str_array_create(int cap) { void str_array_free(str_array *l) { for ( int i = 0; i < l->len ; i++ ) { char * t = l->tokens[ i ]; - if (t) { - zfree(t); - } + zfree(t); } zfree(l); } diff --git a/tests/Makefile.am b/tests/Makefile.am index 21dd302..8edfa58 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -23,7 +23,7 @@ endif if ENABLE_GRAPHVIZ TESTS += check_gvc -check_gvc_SOURCES = check_gvc.c bench.c +check_gvc_SOURCES = check_gvc.c # check_gvc_LDADD = $(GVC_DEPS_LIBS) $(DEPS_LIBS) -L$(top_builddir)/src -lr3 @CHECK_LIBS@ # check_gvc_CFLAGS = $(GVC_DEPS_CFLAGS) $(DEPS_CFLAGS) -I$(top_builddir) -I$(top_builddir)/include @CHECK_CFLAGS@ AM_CFLAGS += $(GVC_DEPS_CFLAGS) @@ -31,9 +31,13 @@ AM_LDFLAGS += $(GVC_DEPS_LIBS) endif +bin_PROGRAMS = benchmark +benchmark_SOURCES = bench.c + + # noinst_PROGRAMS = $(TESTS) -check_tree_SOURCES = check_tree.c bench.c +check_tree_SOURCES = check_tree.c # check_tree_LDADD=$(DEPS_LIBS) -L$(top_builddir)/src -lr3 @CHECK_LIBS@ # check_tree_CFLAGS=$(DEPS_CFLAGS) -I$(top_builddir) -I$(top_builddir)/include @CHECK_CFLAGS@ diff --git a/tests/bench.c b/tests/bench.c index c3ef66b..b92cd89 100644 --- a/tests/bench.c +++ b/tests/bench.c @@ -4,13 +4,21 @@ * * Distributed under terms of the MIT license. */ - -#include "bench.h" -#include +#include "config.h" #include +#include #include +#include /* va_list, va_start, va_arg, va_end */ -long unixtime() { +#include "r3.h" +#include "r3_str.h" +#include "str_array.h" +#include "zmalloc.h" +#include "bench.h" + + + +unsigned long unixtime() { struct timeval tp; long sec = 0L; if (gettimeofday((struct timeval *) &tp, (NUL)) == 0) { @@ -35,7 +43,6 @@ double microtime() { return 0; } - void bench_start(bench *b) { b->start = microtime(); } @@ -58,3 +65,406 @@ void bench_print_summary(bench *b) { printf("finished in %lf seconds\n", bench_duration(b) ); printf("%.2f i/sec\n", bench_iteration_speed(b) ); } + +/** + * Combine multiple benchmark result into one measure entry. + * + * bench_append_csv("benchmark.csv", 3, &b1, &b2) + */ +void bench_append_csv(char *filename, int countOfB, ...) { + FILE *fp = fopen(filename, "a+"); + if(!fp) { + return; + } + + unsigned long ts = unixtime(); + fprintf(fp, "%ld", ts); + + + int i; + bench * b; + va_list vl; + va_start(vl,countOfB); + for (i=0 ; i < countOfB ; i++) { + b = va_arg(vl, bench*); + fprintf(fp, ",%.2f", bench_iteration_speed(b) ); + } + va_end(vl); + + fprintf(fp, "\n"); + fclose(fp); +} + + + +int main() +{ + node * n = r3_tree_create(1); + + int route_data = 999; + +r3_tree_insert_path(n, "/foo/bar/baz", NULL); +r3_tree_insert_path(n, "/foo/bar/qux", NULL); +r3_tree_insert_path(n, "/foo/bar/quux", NULL); +r3_tree_insert_path(n, "/foo/bar/corge", NULL); +r3_tree_insert_path(n, "/foo/bar/grault", NULL); +r3_tree_insert_path(n, "/foo/bar/garply", NULL); +r3_tree_insert_path(n, "/foo/baz/bar", NULL); +r3_tree_insert_path(n, "/foo/baz/qux", NULL); +r3_tree_insert_path(n, "/foo/baz/quux", NULL); +r3_tree_insert_path(n, "/foo/baz/corge", NULL); +r3_tree_insert_path(n, "/foo/baz/grault", NULL); +r3_tree_insert_path(n, "/foo/baz/garply", NULL); +r3_tree_insert_path(n, "/foo/qux/bar", NULL); +r3_tree_insert_path(n, "/foo/qux/baz", NULL); +r3_tree_insert_path(n, "/foo/qux/quux", NULL); +r3_tree_insert_path(n, "/foo/qux/corge", NULL); +r3_tree_insert_path(n, "/foo/qux/grault", NULL); +r3_tree_insert_path(n, "/foo/qux/garply", NULL); +r3_tree_insert_path(n, "/foo/quux/bar", NULL); +r3_tree_insert_path(n, "/foo/quux/baz", NULL); +r3_tree_insert_path(n, "/foo/quux/qux", NULL); +r3_tree_insert_path(n, "/foo/quux/corge", NULL); +r3_tree_insert_path(n, "/foo/quux/grault", NULL); +r3_tree_insert_path(n, "/foo/quux/garply", NULL); +r3_tree_insert_path(n, "/foo/corge/bar", NULL); +r3_tree_insert_path(n, "/foo/corge/baz", NULL); +r3_tree_insert_path(n, "/foo/corge/qux", NULL); +r3_tree_insert_path(n, "/foo/corge/quux", NULL); +r3_tree_insert_path(n, "/foo/corge/grault", NULL); +r3_tree_insert_path(n, "/foo/corge/garply", NULL); +r3_tree_insert_path(n, "/foo/grault/bar", NULL); +r3_tree_insert_path(n, "/foo/grault/baz", NULL); +r3_tree_insert_path(n, "/foo/grault/qux", NULL); +r3_tree_insert_path(n, "/foo/grault/quux", NULL); +r3_tree_insert_path(n, "/foo/grault/corge", NULL); +r3_tree_insert_path(n, "/foo/grault/garply", NULL); +r3_tree_insert_path(n, "/foo/garply/bar", NULL); +r3_tree_insert_path(n, "/foo/garply/baz", NULL); +r3_tree_insert_path(n, "/foo/garply/qux", NULL); +r3_tree_insert_path(n, "/foo/garply/quux", NULL); +r3_tree_insert_path(n, "/foo/garply/corge", NULL); +r3_tree_insert_path(n, "/foo/garply/grault", NULL); +r3_tree_insert_path(n, "/bar/foo/baz", NULL); +r3_tree_insert_path(n, "/bar/foo/qux", NULL); +r3_tree_insert_path(n, "/bar/foo/quux", NULL); +r3_tree_insert_path(n, "/bar/foo/corge", NULL); +r3_tree_insert_path(n, "/bar/foo/grault", NULL); +r3_tree_insert_path(n, "/bar/foo/garply", NULL); +r3_tree_insert_path(n, "/bar/baz/foo", NULL); +r3_tree_insert_path(n, "/bar/baz/qux", NULL); +r3_tree_insert_path(n, "/bar/baz/quux", NULL); +r3_tree_insert_path(n, "/bar/baz/corge", NULL); +r3_tree_insert_path(n, "/bar/baz/grault", NULL); +r3_tree_insert_path(n, "/bar/baz/garply", NULL); +r3_tree_insert_path(n, "/bar/qux/foo", NULL); +r3_tree_insert_path(n, "/bar/qux/baz", NULL); +r3_tree_insert_path(n, "/bar/qux/quux", NULL); +r3_tree_insert_path(n, "/bar/qux/corge", NULL); +r3_tree_insert_path(n, "/bar/qux/grault", NULL); +r3_tree_insert_path(n, "/bar/qux/garply", NULL); +r3_tree_insert_path(n, "/bar/quux/foo", NULL); +r3_tree_insert_path(n, "/bar/quux/baz", NULL); +r3_tree_insert_path(n, "/bar/quux/qux", NULL); +r3_tree_insert_path(n, "/bar/quux/corge", NULL); +r3_tree_insert_path(n, "/bar/quux/grault", NULL); +r3_tree_insert_path(n, "/bar/quux/garply", NULL); +r3_tree_insert_path(n, "/bar/corge/foo", NULL); +r3_tree_insert_path(n, "/bar/corge/baz", NULL); +r3_tree_insert_path(n, "/bar/corge/qux", NULL); +r3_tree_insert_path(n, "/bar/corge/quux", NULL); +r3_tree_insert_path(n, "/bar/corge/grault", NULL); +r3_tree_insert_path(n, "/bar/corge/garply", NULL); +r3_tree_insert_path(n, "/bar/grault/foo", NULL); +r3_tree_insert_path(n, "/bar/grault/baz", NULL); +r3_tree_insert_path(n, "/bar/grault/qux", NULL); +r3_tree_insert_path(n, "/bar/grault/quux", NULL); +r3_tree_insert_path(n, "/bar/grault/corge", NULL); +r3_tree_insert_path(n, "/bar/grault/garply", NULL); +r3_tree_insert_path(n, "/bar/garply/foo", NULL); +r3_tree_insert_path(n, "/bar/garply/baz", NULL); +r3_tree_insert_path(n, "/bar/garply/qux", NULL); +r3_tree_insert_path(n, "/bar/garply/quux", NULL); +r3_tree_insert_path(n, "/bar/garply/corge", NULL); +r3_tree_insert_path(n, "/bar/garply/grault", NULL); +r3_tree_insert_path(n, "/baz/foo/bar", NULL); +r3_tree_insert_path(n, "/baz/foo/qux", NULL); +r3_tree_insert_path(n, "/baz/foo/quux", NULL); +r3_tree_insert_path(n, "/baz/foo/corge", NULL); +r3_tree_insert_path(n, "/baz/foo/grault", NULL); +r3_tree_insert_path(n, "/baz/foo/garply", NULL); +r3_tree_insert_path(n, "/baz/bar/foo", NULL); +r3_tree_insert_path(n, "/baz/bar/qux", NULL); +r3_tree_insert_path(n, "/baz/bar/quux", NULL); +r3_tree_insert_path(n, "/baz/bar/corge", NULL); +r3_tree_insert_path(n, "/baz/bar/grault", NULL); +r3_tree_insert_path(n, "/baz/bar/garply", NULL); +r3_tree_insert_path(n, "/baz/qux/foo", NULL); +r3_tree_insert_path(n, "/baz/qux/bar", NULL); +r3_tree_insert_path(n, "/baz/qux/quux", NULL); +r3_tree_insert_path(n, "/baz/qux/corge", NULL); +r3_tree_insert_path(n, "/baz/qux/grault", NULL); +r3_tree_insert_path(n, "/baz/qux/garply", NULL); +r3_tree_insert_path(n, "/baz/quux/foo", NULL); +r3_tree_insert_path(n, "/baz/quux/bar", NULL); +r3_tree_insert_path(n, "/baz/quux/qux", NULL); +r3_tree_insert_path(n, "/baz/quux/corge", NULL); +r3_tree_insert_path(n, "/baz/quux/grault", NULL); +r3_tree_insert_path(n, "/baz/quux/garply", NULL); +r3_tree_insert_path(n, "/baz/corge/foo", NULL); +r3_tree_insert_path(n, "/baz/corge/bar", NULL); +r3_tree_insert_path(n, "/baz/corge/qux", NULL); +r3_tree_insert_path(n, "/baz/corge/quux", NULL); +r3_tree_insert_path(n, "/baz/corge/grault", NULL); +r3_tree_insert_path(n, "/baz/corge/garply", NULL); +r3_tree_insert_path(n, "/baz/grault/foo", NULL); +r3_tree_insert_path(n, "/baz/grault/bar", NULL); +r3_tree_insert_path(n, "/baz/grault/qux", NULL); +r3_tree_insert_path(n, "/baz/grault/quux", NULL); +r3_tree_insert_path(n, "/baz/grault/corge", NULL); +r3_tree_insert_path(n, "/baz/grault/garply", NULL); +r3_tree_insert_path(n, "/baz/garply/foo", NULL); +r3_tree_insert_path(n, "/baz/garply/bar", NULL); +r3_tree_insert_path(n, "/baz/garply/qux", NULL); +r3_tree_insert_path(n, "/baz/garply/quux", NULL); +r3_tree_insert_path(n, "/baz/garply/corge", NULL); +r3_tree_insert_path(n, "/baz/garply/grault", NULL); +r3_tree_insert_path(n, "/qux/foo/bar", NULL); +r3_tree_insert_path(n, "/qux/foo/baz", NULL); +r3_tree_insert_path(n, "/qux/foo/quux", NULL); +r3_tree_insert_path(n, "/qux/foo/corge", NULL); +r3_tree_insert_path(n, "/qux/foo/grault", NULL); +r3_tree_insert_path(n, "/qux/foo/garply", NULL); +r3_tree_insert_path(n, "/qux/bar/foo", NULL); +r3_tree_insert_path(n, "/qux/bar/baz", NULL); +r3_tree_insert_path(n, "/qux/bar/quux", NULL); +r3_tree_insert_path(n, "/qux/bar/corge", &route_data); +r3_tree_insert_path(n, "/qux/bar/grault", NULL); +r3_tree_insert_path(n, "/qux/bar/garply", NULL); +r3_tree_insert_path(n, "/qux/baz/foo", NULL); +r3_tree_insert_path(n, "/qux/baz/bar", NULL); +r3_tree_insert_path(n, "/qux/baz/quux", NULL); +r3_tree_insert_path(n, "/qux/baz/corge", NULL); +r3_tree_insert_path(n, "/qux/baz/grault", NULL); +r3_tree_insert_path(n, "/qux/baz/garply", NULL); +r3_tree_insert_path(n, "/qux/quux/foo", NULL); +r3_tree_insert_path(n, "/qux/quux/bar", NULL); +r3_tree_insert_path(n, "/qux/quux/baz", NULL); +r3_tree_insert_path(n, "/qux/quux/corge", NULL); +r3_tree_insert_path(n, "/qux/quux/grault", NULL); +r3_tree_insert_path(n, "/qux/quux/garply", NULL); +r3_tree_insert_path(n, "/qux/corge/foo", NULL); +r3_tree_insert_path(n, "/qux/corge/bar", NULL); +r3_tree_insert_path(n, "/qux/corge/baz", NULL); +r3_tree_insert_path(n, "/qux/corge/quux", NULL); +r3_tree_insert_path(n, "/qux/corge/grault", NULL); +r3_tree_insert_path(n, "/qux/corge/garply", NULL); +r3_tree_insert_path(n, "/qux/grault/foo", NULL); +r3_tree_insert_path(n, "/qux/grault/bar", NULL); +r3_tree_insert_path(n, "/qux/grault/baz", NULL); +r3_tree_insert_path(n, "/qux/grault/quux", NULL); +r3_tree_insert_path(n, "/qux/grault/corge", NULL); +r3_tree_insert_path(n, "/qux/grault/garply", NULL); +r3_tree_insert_path(n, "/qux/garply/foo", NULL); +r3_tree_insert_path(n, "/qux/garply/bar", NULL); +r3_tree_insert_path(n, "/qux/garply/baz", NULL); +r3_tree_insert_path(n, "/qux/garply/quux", NULL); +r3_tree_insert_path(n, "/qux/garply/corge", NULL); +r3_tree_insert_path(n, "/qux/garply/grault", NULL); +r3_tree_insert_path(n, "/quux/foo/bar", NULL); +r3_tree_insert_path(n, "/quux/foo/baz", NULL); +r3_tree_insert_path(n, "/quux/foo/qux", NULL); +r3_tree_insert_path(n, "/quux/foo/corge", NULL); +r3_tree_insert_path(n, "/quux/foo/grault", NULL); +r3_tree_insert_path(n, "/quux/foo/garply", NULL); +r3_tree_insert_path(n, "/quux/bar/foo", NULL); +r3_tree_insert_path(n, "/quux/bar/baz", NULL); +r3_tree_insert_path(n, "/quux/bar/qux", NULL); +r3_tree_insert_path(n, "/quux/bar/corge", NULL); +r3_tree_insert_path(n, "/quux/bar/grault", NULL); +r3_tree_insert_path(n, "/quux/bar/garply", NULL); +r3_tree_insert_path(n, "/quux/baz/foo", NULL); +r3_tree_insert_path(n, "/quux/baz/bar", NULL); +r3_tree_insert_path(n, "/quux/baz/qux", NULL); +r3_tree_insert_path(n, "/quux/baz/corge", NULL); +r3_tree_insert_path(n, "/quux/baz/grault", NULL); +r3_tree_insert_path(n, "/quux/baz/garply", NULL); +r3_tree_insert_path(n, "/quux/qux/foo", NULL); +r3_tree_insert_path(n, "/quux/qux/bar", NULL); +r3_tree_insert_path(n, "/quux/qux/baz", NULL); +r3_tree_insert_path(n, "/quux/qux/corge", NULL); +r3_tree_insert_path(n, "/quux/qux/grault", NULL); +r3_tree_insert_path(n, "/quux/qux/garply", NULL); +r3_tree_insert_path(n, "/quux/corge/foo", NULL); +r3_tree_insert_path(n, "/quux/corge/bar", NULL); +r3_tree_insert_path(n, "/quux/corge/baz", NULL); +r3_tree_insert_path(n, "/quux/corge/qux", NULL); +r3_tree_insert_path(n, "/quux/corge/grault", NULL); +r3_tree_insert_path(n, "/quux/corge/garply", NULL); +r3_tree_insert_path(n, "/quux/grault/foo", NULL); +r3_tree_insert_path(n, "/quux/grault/bar", NULL); +r3_tree_insert_path(n, "/quux/grault/baz", NULL); +r3_tree_insert_path(n, "/quux/grault/qux", NULL); +r3_tree_insert_path(n, "/quux/grault/corge", NULL); +r3_tree_insert_path(n, "/quux/grault/garply", NULL); +r3_tree_insert_path(n, "/quux/garply/foo", NULL); +r3_tree_insert_path(n, "/quux/garply/bar", NULL); +r3_tree_insert_path(n, "/quux/garply/baz", NULL); +r3_tree_insert_path(n, "/quux/garply/qux", NULL); +r3_tree_insert_path(n, "/quux/garply/corge", NULL); +r3_tree_insert_path(n, "/quux/garply/grault", NULL); +r3_tree_insert_path(n, "/corge/foo/bar", NULL); +r3_tree_insert_path(n, "/corge/foo/baz", NULL); +r3_tree_insert_path(n, "/corge/foo/qux", NULL); +r3_tree_insert_path(n, "/corge/foo/quux", NULL); +r3_tree_insert_path(n, "/corge/foo/grault", NULL); +r3_tree_insert_path(n, "/corge/foo/garply", NULL); +r3_tree_insert_path(n, "/corge/bar/foo", NULL); +r3_tree_insert_path(n, "/corge/bar/baz", NULL); +r3_tree_insert_path(n, "/corge/bar/qux", NULL); +r3_tree_insert_path(n, "/corge/bar/quux", NULL); +r3_tree_insert_path(n, "/corge/bar/grault", NULL); +r3_tree_insert_path(n, "/corge/bar/garply", NULL); +r3_tree_insert_path(n, "/corge/baz/foo", NULL); +r3_tree_insert_path(n, "/corge/baz/bar", NULL); +r3_tree_insert_path(n, "/corge/baz/qux", NULL); +r3_tree_insert_path(n, "/corge/baz/quux", NULL); +r3_tree_insert_path(n, "/corge/baz/grault", NULL); +r3_tree_insert_path(n, "/corge/baz/garply", NULL); +r3_tree_insert_path(n, "/corge/qux/foo", NULL); +r3_tree_insert_path(n, "/corge/qux/bar", NULL); +r3_tree_insert_path(n, "/corge/qux/baz", NULL); +r3_tree_insert_path(n, "/corge/qux/quux", NULL); +r3_tree_insert_path(n, "/corge/qux/grault", NULL); +r3_tree_insert_path(n, "/corge/qux/garply", NULL); +r3_tree_insert_path(n, "/corge/quux/foo", NULL); +r3_tree_insert_path(n, "/corge/quux/bar", NULL); +r3_tree_insert_path(n, "/corge/quux/baz", NULL); +r3_tree_insert_path(n, "/corge/quux/qux", NULL); +r3_tree_insert_path(n, "/corge/quux/grault", NULL); +r3_tree_insert_path(n, "/corge/quux/garply", NULL); +r3_tree_insert_path(n, "/corge/grault/foo", NULL); +r3_tree_insert_path(n, "/corge/grault/bar", NULL); +r3_tree_insert_path(n, "/corge/grault/baz", NULL); +r3_tree_insert_path(n, "/corge/grault/qux", NULL); +r3_tree_insert_path(n, "/corge/grault/quux", NULL); +r3_tree_insert_path(n, "/corge/grault/garply", NULL); +r3_tree_insert_path(n, "/corge/garply/foo", NULL); +r3_tree_insert_path(n, "/corge/garply/bar", NULL); +r3_tree_insert_path(n, "/corge/garply/baz", NULL); +r3_tree_insert_path(n, "/corge/garply/qux", NULL); +r3_tree_insert_path(n, "/corge/garply/quux", NULL); +r3_tree_insert_path(n, "/corge/garply/grault", NULL); +r3_tree_insert_path(n, "/grault/foo/bar", NULL); +r3_tree_insert_path(n, "/grault/foo/baz", NULL); +r3_tree_insert_path(n, "/grault/foo/qux", NULL); +r3_tree_insert_path(n, "/grault/foo/quux", NULL); +r3_tree_insert_path(n, "/grault/foo/corge", NULL); +r3_tree_insert_path(n, "/grault/foo/garply", NULL); +r3_tree_insert_path(n, "/grault/bar/foo", NULL); +r3_tree_insert_path(n, "/grault/bar/baz", NULL); +r3_tree_insert_path(n, "/grault/bar/qux", NULL); +r3_tree_insert_path(n, "/grault/bar/quux", NULL); +r3_tree_insert_path(n, "/grault/bar/corge", NULL); +r3_tree_insert_path(n, "/grault/bar/garply", NULL); +r3_tree_insert_path(n, "/grault/baz/foo", NULL); +r3_tree_insert_path(n, "/grault/baz/bar", NULL); +r3_tree_insert_path(n, "/grault/baz/qux", NULL); +r3_tree_insert_path(n, "/grault/baz/quux", NULL); +r3_tree_insert_path(n, "/grault/baz/corge", NULL); +r3_tree_insert_path(n, "/grault/baz/garply", NULL); +r3_tree_insert_path(n, "/grault/qux/foo", NULL); +r3_tree_insert_path(n, "/grault/qux/bar", NULL); +r3_tree_insert_path(n, "/grault/qux/baz", NULL); +r3_tree_insert_path(n, "/grault/qux/quux", NULL); +r3_tree_insert_path(n, "/grault/qux/corge", NULL); +r3_tree_insert_path(n, "/grault/qux/garply", NULL); +r3_tree_insert_path(n, "/grault/quux/foo", NULL); +r3_tree_insert_path(n, "/grault/quux/bar", NULL); +r3_tree_insert_path(n, "/grault/quux/baz", NULL); +r3_tree_insert_path(n, "/grault/quux/qux", NULL); +r3_tree_insert_path(n, "/grault/quux/corge", NULL); +r3_tree_insert_path(n, "/grault/quux/garply", NULL); +r3_tree_insert_path(n, "/grault/corge/foo", NULL); +r3_tree_insert_path(n, "/grault/corge/bar", NULL); +r3_tree_insert_path(n, "/grault/corge/baz", NULL); +r3_tree_insert_path(n, "/grault/corge/qux", NULL); +r3_tree_insert_path(n, "/grault/corge/quux", NULL); +r3_tree_insert_path(n, "/grault/corge/garply", NULL); +r3_tree_insert_path(n, "/grault/garply/foo", NULL); +r3_tree_insert_path(n, "/grault/garply/bar", NULL); +r3_tree_insert_path(n, "/grault/garply/baz", NULL); +r3_tree_insert_path(n, "/grault/garply/qux", NULL); +r3_tree_insert_path(n, "/grault/garply/quux", NULL); +r3_tree_insert_path(n, "/grault/garply/corge", NULL); +r3_tree_insert_path(n, "/garply/foo/bar", NULL); +r3_tree_insert_path(n, "/garply/foo/baz", NULL); +r3_tree_insert_path(n, "/garply/foo/qux", NULL); +r3_tree_insert_path(n, "/garply/foo/quux", NULL); +r3_tree_insert_path(n, "/garply/foo/corge", NULL); +r3_tree_insert_path(n, "/garply/foo/grault", NULL); +r3_tree_insert_path(n, "/garply/bar/foo", NULL); +r3_tree_insert_path(n, "/garply/bar/baz", NULL); +r3_tree_insert_path(n, "/garply/bar/qux", NULL); +r3_tree_insert_path(n, "/garply/bar/quux", NULL); +r3_tree_insert_path(n, "/garply/bar/corge", NULL); +r3_tree_insert_path(n, "/garply/bar/grault", NULL); +r3_tree_insert_path(n, "/garply/baz/foo", NULL); +r3_tree_insert_path(n, "/garply/baz/bar", NULL); +r3_tree_insert_path(n, "/garply/baz/qux", NULL); +r3_tree_insert_path(n, "/garply/baz/quux", NULL); +r3_tree_insert_path(n, "/garply/baz/corge", NULL); +r3_tree_insert_path(n, "/garply/baz/grault", NULL); +r3_tree_insert_path(n, "/garply/qux/foo", NULL); +r3_tree_insert_path(n, "/garply/qux/bar", NULL); +r3_tree_insert_path(n, "/garply/qux/baz", NULL); +r3_tree_insert_path(n, "/garply/qux/quux", NULL); +r3_tree_insert_path(n, "/garply/qux/corge", NULL); +r3_tree_insert_path(n, "/garply/qux/grault", NULL); +r3_tree_insert_path(n, "/garply/quux/foo", NULL); +r3_tree_insert_path(n, "/garply/quux/bar", NULL); +r3_tree_insert_path(n, "/garply/quux/baz", NULL); +r3_tree_insert_path(n, "/garply/quux/qux", NULL); +r3_tree_insert_path(n, "/garply/quux/corge", NULL); +r3_tree_insert_path(n, "/garply/quux/grault", NULL); +r3_tree_insert_path(n, "/garply/corge/foo", NULL); +r3_tree_insert_path(n, "/garply/corge/bar", NULL); +r3_tree_insert_path(n, "/garply/corge/baz", NULL); +r3_tree_insert_path(n, "/garply/corge/qux", NULL); +r3_tree_insert_path(n, "/garply/corge/quux", NULL); +r3_tree_insert_path(n, "/garply/corge/grault", NULL); +r3_tree_insert_path(n, "/garply/grault/foo", NULL); +r3_tree_insert_path(n, "/garply/grault/bar", NULL); +r3_tree_insert_path(n, "/garply/grault/baz", NULL); +r3_tree_insert_path(n, "/garply/grault/qux", NULL); +r3_tree_insert_path(n, "/garply/grault/quux", NULL); +r3_tree_insert_path(n, "/garply/grault/corge", NULL); + + MEASURE(tree_compile) + r3_tree_compile(n); + END_MEASURE(tree_compile) + + node *m; + m = r3_tree_match(n , "/qux/bar/corge", NULL); + assert(m != NULL); + assert( *((int*) m->data) == 999 ); + + + BENCHMARK(string_dispatch) + r3_tree_matchl(n , "/qux/bar/corge", strlen("/qux/bar/corge"), NULL); + END_BENCHMARK(string_dispatch) + BENCHMARK_SUMMARY(string_dispatch); + + + node * tree2 = r3_tree_create(1); + r3_tree_insert_path(tree2, "/post/{year}/{month}", NULL); + r3_tree_compile(tree2); + + BENCHMARK(pcre_dispatch) + r3_tree_matchl(tree2, "/post/2014/12", strlen("/post/2014/12"), NULL); + END_BENCHMARK(pcre_dispatch) + BENCHMARK_SUMMARY(pcre_dispatch); + + BENCHMARK_RECORD_CSV("bench_str.csv", 3, BR(string_dispatch), BR(pcre_dispatch), BR(tree_compile) ); + return 0; +} diff --git a/tests/bench.h b/tests/bench.h index 0d4c898..a4c02c4 100644 --- a/tests/bench.h +++ b/tests/bench.h @@ -14,7 +14,6 @@ #define SEC_IN_MIN 60 #define NUL '\0' - typedef struct { long N; // N for each run long R; // runs @@ -23,7 +22,7 @@ typedef struct { double end; } bench; -long unixtime(); +unsigned long unixtime(); double microtime(); @@ -37,6 +36,36 @@ void bench_print_summary(bench *b); double bench_duration(bench *b); +void bench_append_csv(char *filename, int countOfB, ...); + +#define MEASURE(B) \ + bench B; B.N = 1; B.R = 1; \ + printf("Measuring " #B "...\n"); \ + bench_start(&B); + +#define END_MEASURE(B) \ + bench_stop(&B); + +#define BENCHMARK(B) \ + bench B; B.N = 5000000; B.R = 3; \ + printf("Benchmarking " #B "...\n"); \ + bench_start(&B); \ + for (int _r = 0; _r < B.R ; _r++ ) { \ + for (int _i = 0; _i < B.N ; _i++ ) { + +#define END_BENCHMARK(B) \ + } \ + } \ + bench_stop(&B); + +#define BENCHMARK_SUMMARY(B) bench_print_summary(&B); + +#define BENCHMARK_RECORD_CSV(filename, countOfB, ...) \ + bench_append_csv(filename, countOfB, __VA_ARGS__) + +#define BR(b) &b + + #define BENCHMARK(B) \ bench B; B.N = 5000000; B.R = 3; \ bench_start(&B); \ diff --git a/tests/bench_str.csv b/tests/bench_str.csv index 08bedda..2f43ac7 100644 --- a/tests/bench_str.csv +++ b/tests/bench_str.csv @@ -454,18 +454,14 @@ 1400749599,13245418.70 1400749614,12494314.81 1400749643,12690632.63 -1400749676,10154614.63 -1400749681,10313142.07 -1400749696,10511488.62 -1400749780,10359781.60 -1400749808,10187594.58 -1400749822,10446286.96 -1400749888,10342786.49 -1400749944,10491740.29 -1400749951,10544104.04 1400750350,10391028.46 1400750424,9445761.22 1400750472,9248611.74 1400750479,10757562.36 1400750512,10126746.58 1400750536,10568568.26 +1400762875,10472029.42 +1400764426,10066458.45,1590373.41 +1400765068,10657617.64,2131810.12 +1400766518,10259200.94,1878279.25,96697.86 +1400766623,11057429.08,2113683.19,95835.70 diff --git a/tests/check_slug.c b/tests/check_slug.c index 2662981..1453fd2 100644 --- a/tests/check_slug.c +++ b/tests/check_slug.c @@ -98,6 +98,7 @@ END_TEST Suite* r3_suite (void) { Suite *suite = suite_create("slug test"); TCase *tcase = tcase_create("test_slug"); + tcase_set_timeout(tcase, 30); tcase_add_test(tcase, test_contains_slug); tcase_add_test(tcase, test_inside_slug); tcase_add_test(tcase, test_find_slug_pattern); diff --git a/tests/check_tree.c b/tests/check_tree.c index b94f28a..ec3697c 100644 --- a/tests/check_tree.c +++ b/tests/check_tree.c @@ -359,376 +359,6 @@ START_TEST(test_insert_route) END_TEST - -START_TEST(benchmark_str) -{ - match_entry * entry = match_entry_createl("/blog/post", strlen("/blog/post") ); - node * n = r3_tree_create(1); - - - int route_data = 999; - -r3_tree_insert_path(n, "/foo/bar/baz", NULL); -r3_tree_insert_path(n, "/foo/bar/qux", NULL); -r3_tree_insert_path(n, "/foo/bar/quux", NULL); -r3_tree_insert_path(n, "/foo/bar/corge", NULL); -r3_tree_insert_path(n, "/foo/bar/grault", NULL); -r3_tree_insert_path(n, "/foo/bar/garply", NULL); -r3_tree_insert_path(n, "/foo/baz/bar", NULL); -r3_tree_insert_path(n, "/foo/baz/qux", NULL); -r3_tree_insert_path(n, "/foo/baz/quux", NULL); -r3_tree_insert_path(n, "/foo/baz/corge", NULL); -r3_tree_insert_path(n, "/foo/baz/grault", NULL); -r3_tree_insert_path(n, "/foo/baz/garply", NULL); -r3_tree_insert_path(n, "/foo/qux/bar", NULL); -r3_tree_insert_path(n, "/foo/qux/baz", NULL); -r3_tree_insert_path(n, "/foo/qux/quux", NULL); -r3_tree_insert_path(n, "/foo/qux/corge", NULL); -r3_tree_insert_path(n, "/foo/qux/grault", NULL); -r3_tree_insert_path(n, "/foo/qux/garply", NULL); -r3_tree_insert_path(n, "/foo/quux/bar", NULL); -r3_tree_insert_path(n, "/foo/quux/baz", NULL); -r3_tree_insert_path(n, "/foo/quux/qux", NULL); -r3_tree_insert_path(n, "/foo/quux/corge", NULL); -r3_tree_insert_path(n, "/foo/quux/grault", NULL); -r3_tree_insert_path(n, "/foo/quux/garply", NULL); -r3_tree_insert_path(n, "/foo/corge/bar", NULL); -r3_tree_insert_path(n, "/foo/corge/baz", NULL); -r3_tree_insert_path(n, "/foo/corge/qux", NULL); -r3_tree_insert_path(n, "/foo/corge/quux", NULL); -r3_tree_insert_path(n, "/foo/corge/grault", NULL); -r3_tree_insert_path(n, "/foo/corge/garply", NULL); -r3_tree_insert_path(n, "/foo/grault/bar", NULL); -r3_tree_insert_path(n, "/foo/grault/baz", NULL); -r3_tree_insert_path(n, "/foo/grault/qux", NULL); -r3_tree_insert_path(n, "/foo/grault/quux", NULL); -r3_tree_insert_path(n, "/foo/grault/corge", NULL); -r3_tree_insert_path(n, "/foo/grault/garply", NULL); -r3_tree_insert_path(n, "/foo/garply/bar", NULL); -r3_tree_insert_path(n, "/foo/garply/baz", NULL); -r3_tree_insert_path(n, "/foo/garply/qux", NULL); -r3_tree_insert_path(n, "/foo/garply/quux", NULL); -r3_tree_insert_path(n, "/foo/garply/corge", NULL); -r3_tree_insert_path(n, "/foo/garply/grault", NULL); -r3_tree_insert_path(n, "/bar/foo/baz", NULL); -r3_tree_insert_path(n, "/bar/foo/qux", NULL); -r3_tree_insert_path(n, "/bar/foo/quux", NULL); -r3_tree_insert_path(n, "/bar/foo/corge", NULL); -r3_tree_insert_path(n, "/bar/foo/grault", NULL); -r3_tree_insert_path(n, "/bar/foo/garply", NULL); -r3_tree_insert_path(n, "/bar/baz/foo", NULL); -r3_tree_insert_path(n, "/bar/baz/qux", NULL); -r3_tree_insert_path(n, "/bar/baz/quux", NULL); -r3_tree_insert_path(n, "/bar/baz/corge", NULL); -r3_tree_insert_path(n, "/bar/baz/grault", NULL); -r3_tree_insert_path(n, "/bar/baz/garply", NULL); -r3_tree_insert_path(n, "/bar/qux/foo", NULL); -r3_tree_insert_path(n, "/bar/qux/baz", NULL); -r3_tree_insert_path(n, "/bar/qux/quux", NULL); -r3_tree_insert_path(n, "/bar/qux/corge", NULL); -r3_tree_insert_path(n, "/bar/qux/grault", NULL); -r3_tree_insert_path(n, "/bar/qux/garply", NULL); -r3_tree_insert_path(n, "/bar/quux/foo", NULL); -r3_tree_insert_path(n, "/bar/quux/baz", NULL); -r3_tree_insert_path(n, "/bar/quux/qux", NULL); -r3_tree_insert_path(n, "/bar/quux/corge", NULL); -r3_tree_insert_path(n, "/bar/quux/grault", NULL); -r3_tree_insert_path(n, "/bar/quux/garply", NULL); -r3_tree_insert_path(n, "/bar/corge/foo", NULL); -r3_tree_insert_path(n, "/bar/corge/baz", NULL); -r3_tree_insert_path(n, "/bar/corge/qux", NULL); -r3_tree_insert_path(n, "/bar/corge/quux", NULL); -r3_tree_insert_path(n, "/bar/corge/grault", NULL); -r3_tree_insert_path(n, "/bar/corge/garply", NULL); -r3_tree_insert_path(n, "/bar/grault/foo", NULL); -r3_tree_insert_path(n, "/bar/grault/baz", NULL); -r3_tree_insert_path(n, "/bar/grault/qux", NULL); -r3_tree_insert_path(n, "/bar/grault/quux", NULL); -r3_tree_insert_path(n, "/bar/grault/corge", NULL); -r3_tree_insert_path(n, "/bar/grault/garply", NULL); -r3_tree_insert_path(n, "/bar/garply/foo", NULL); -r3_tree_insert_path(n, "/bar/garply/baz", NULL); -r3_tree_insert_path(n, "/bar/garply/qux", NULL); -r3_tree_insert_path(n, "/bar/garply/quux", NULL); -r3_tree_insert_path(n, "/bar/garply/corge", NULL); -r3_tree_insert_path(n, "/bar/garply/grault", NULL); -r3_tree_insert_path(n, "/baz/foo/bar", NULL); -r3_tree_insert_path(n, "/baz/foo/qux", NULL); -r3_tree_insert_path(n, "/baz/foo/quux", NULL); -r3_tree_insert_path(n, "/baz/foo/corge", NULL); -r3_tree_insert_path(n, "/baz/foo/grault", NULL); -r3_tree_insert_path(n, "/baz/foo/garply", NULL); -r3_tree_insert_path(n, "/baz/bar/foo", NULL); -r3_tree_insert_path(n, "/baz/bar/qux", NULL); -r3_tree_insert_path(n, "/baz/bar/quux", NULL); -r3_tree_insert_path(n, "/baz/bar/corge", NULL); -r3_tree_insert_path(n, "/baz/bar/grault", NULL); -r3_tree_insert_path(n, "/baz/bar/garply", NULL); -r3_tree_insert_path(n, "/baz/qux/foo", NULL); -r3_tree_insert_path(n, "/baz/qux/bar", NULL); -r3_tree_insert_path(n, "/baz/qux/quux", NULL); -r3_tree_insert_path(n, "/baz/qux/corge", NULL); -r3_tree_insert_path(n, "/baz/qux/grault", NULL); -r3_tree_insert_path(n, "/baz/qux/garply", NULL); -r3_tree_insert_path(n, "/baz/quux/foo", NULL); -r3_tree_insert_path(n, "/baz/quux/bar", NULL); -r3_tree_insert_path(n, "/baz/quux/qux", NULL); -r3_tree_insert_path(n, "/baz/quux/corge", NULL); -r3_tree_insert_path(n, "/baz/quux/grault", NULL); -r3_tree_insert_path(n, "/baz/quux/garply", NULL); -r3_tree_insert_path(n, "/baz/corge/foo", NULL); -r3_tree_insert_path(n, "/baz/corge/bar", NULL); -r3_tree_insert_path(n, "/baz/corge/qux", NULL); -r3_tree_insert_path(n, "/baz/corge/quux", NULL); -r3_tree_insert_path(n, "/baz/corge/grault", NULL); -r3_tree_insert_path(n, "/baz/corge/garply", NULL); -r3_tree_insert_path(n, "/baz/grault/foo", NULL); -r3_tree_insert_path(n, "/baz/grault/bar", NULL); -r3_tree_insert_path(n, "/baz/grault/qux", NULL); -r3_tree_insert_path(n, "/baz/grault/quux", NULL); -r3_tree_insert_path(n, "/baz/grault/corge", NULL); -r3_tree_insert_path(n, "/baz/grault/garply", NULL); -r3_tree_insert_path(n, "/baz/garply/foo", NULL); -r3_tree_insert_path(n, "/baz/garply/bar", NULL); -r3_tree_insert_path(n, "/baz/garply/qux", NULL); -r3_tree_insert_path(n, "/baz/garply/quux", NULL); -r3_tree_insert_path(n, "/baz/garply/corge", NULL); -r3_tree_insert_path(n, "/baz/garply/grault", NULL); -r3_tree_insert_path(n, "/qux/foo/bar", NULL); -r3_tree_insert_path(n, "/qux/foo/baz", NULL); -r3_tree_insert_path(n, "/qux/foo/quux", NULL); -r3_tree_insert_path(n, "/qux/foo/corge", NULL); -r3_tree_insert_path(n, "/qux/foo/grault", NULL); -r3_tree_insert_path(n, "/qux/foo/garply", NULL); -r3_tree_insert_path(n, "/qux/bar/foo", NULL); -r3_tree_insert_path(n, "/qux/bar/baz", NULL); -r3_tree_insert_path(n, "/qux/bar/quux", NULL); -r3_tree_insert_path(n, "/qux/bar/corge", &route_data); -r3_tree_insert_path(n, "/qux/bar/grault", NULL); -r3_tree_insert_path(n, "/qux/bar/garply", NULL); -r3_tree_insert_path(n, "/qux/baz/foo", NULL); -r3_tree_insert_path(n, "/qux/baz/bar", NULL); -r3_tree_insert_path(n, "/qux/baz/quux", NULL); -r3_tree_insert_path(n, "/qux/baz/corge", NULL); -r3_tree_insert_path(n, "/qux/baz/grault", NULL); -r3_tree_insert_path(n, "/qux/baz/garply", NULL); -r3_tree_insert_path(n, "/qux/quux/foo", NULL); -r3_tree_insert_path(n, "/qux/quux/bar", NULL); -r3_tree_insert_path(n, "/qux/quux/baz", NULL); -r3_tree_insert_path(n, "/qux/quux/corge", NULL); -r3_tree_insert_path(n, "/qux/quux/grault", NULL); -r3_tree_insert_path(n, "/qux/quux/garply", NULL); -r3_tree_insert_path(n, "/qux/corge/foo", NULL); -r3_tree_insert_path(n, "/qux/corge/bar", NULL); -r3_tree_insert_path(n, "/qux/corge/baz", NULL); -r3_tree_insert_path(n, "/qux/corge/quux", NULL); -r3_tree_insert_path(n, "/qux/corge/grault", NULL); -r3_tree_insert_path(n, "/qux/corge/garply", NULL); -r3_tree_insert_path(n, "/qux/grault/foo", NULL); -r3_tree_insert_path(n, "/qux/grault/bar", NULL); -r3_tree_insert_path(n, "/qux/grault/baz", NULL); -r3_tree_insert_path(n, "/qux/grault/quux", NULL); -r3_tree_insert_path(n, "/qux/grault/corge", NULL); -r3_tree_insert_path(n, "/qux/grault/garply", NULL); -r3_tree_insert_path(n, "/qux/garply/foo", NULL); -r3_tree_insert_path(n, "/qux/garply/bar", NULL); -r3_tree_insert_path(n, "/qux/garply/baz", NULL); -r3_tree_insert_path(n, "/qux/garply/quux", NULL); -r3_tree_insert_path(n, "/qux/garply/corge", NULL); -r3_tree_insert_path(n, "/qux/garply/grault", NULL); -r3_tree_insert_path(n, "/quux/foo/bar", NULL); -r3_tree_insert_path(n, "/quux/foo/baz", NULL); -r3_tree_insert_path(n, "/quux/foo/qux", NULL); -r3_tree_insert_path(n, "/quux/foo/corge", NULL); -r3_tree_insert_path(n, "/quux/foo/grault", NULL); -r3_tree_insert_path(n, "/quux/foo/garply", NULL); -r3_tree_insert_path(n, "/quux/bar/foo", NULL); -r3_tree_insert_path(n, "/quux/bar/baz", NULL); -r3_tree_insert_path(n, "/quux/bar/qux", NULL); -r3_tree_insert_path(n, "/quux/bar/corge", NULL); -r3_tree_insert_path(n, "/quux/bar/grault", NULL); -r3_tree_insert_path(n, "/quux/bar/garply", NULL); -r3_tree_insert_path(n, "/quux/baz/foo", NULL); -r3_tree_insert_path(n, "/quux/baz/bar", NULL); -r3_tree_insert_path(n, "/quux/baz/qux", NULL); -r3_tree_insert_path(n, "/quux/baz/corge", NULL); -r3_tree_insert_path(n, "/quux/baz/grault", NULL); -r3_tree_insert_path(n, "/quux/baz/garply", NULL); -r3_tree_insert_path(n, "/quux/qux/foo", NULL); -r3_tree_insert_path(n, "/quux/qux/bar", NULL); -r3_tree_insert_path(n, "/quux/qux/baz", NULL); -r3_tree_insert_path(n, "/quux/qux/corge", NULL); -r3_tree_insert_path(n, "/quux/qux/grault", NULL); -r3_tree_insert_path(n, "/quux/qux/garply", NULL); -r3_tree_insert_path(n, "/quux/corge/foo", NULL); -r3_tree_insert_path(n, "/quux/corge/bar", NULL); -r3_tree_insert_path(n, "/quux/corge/baz", NULL); -r3_tree_insert_path(n, "/quux/corge/qux", NULL); -r3_tree_insert_path(n, "/quux/corge/grault", NULL); -r3_tree_insert_path(n, "/quux/corge/garply", NULL); -r3_tree_insert_path(n, "/quux/grault/foo", NULL); -r3_tree_insert_path(n, "/quux/grault/bar", NULL); -r3_tree_insert_path(n, "/quux/grault/baz", NULL); -r3_tree_insert_path(n, "/quux/grault/qux", NULL); -r3_tree_insert_path(n, "/quux/grault/corge", NULL); -r3_tree_insert_path(n, "/quux/grault/garply", NULL); -r3_tree_insert_path(n, "/quux/garply/foo", NULL); -r3_tree_insert_path(n, "/quux/garply/bar", NULL); -r3_tree_insert_path(n, "/quux/garply/baz", NULL); -r3_tree_insert_path(n, "/quux/garply/qux", NULL); -r3_tree_insert_path(n, "/quux/garply/corge", NULL); -r3_tree_insert_path(n, "/quux/garply/grault", NULL); -r3_tree_insert_path(n, "/corge/foo/bar", NULL); -r3_tree_insert_path(n, "/corge/foo/baz", NULL); -r3_tree_insert_path(n, "/corge/foo/qux", NULL); -r3_tree_insert_path(n, "/corge/foo/quux", NULL); -r3_tree_insert_path(n, "/corge/foo/grault", NULL); -r3_tree_insert_path(n, "/corge/foo/garply", NULL); -r3_tree_insert_path(n, "/corge/bar/foo", NULL); -r3_tree_insert_path(n, "/corge/bar/baz", NULL); -r3_tree_insert_path(n, "/corge/bar/qux", NULL); -r3_tree_insert_path(n, "/corge/bar/quux", NULL); -r3_tree_insert_path(n, "/corge/bar/grault", NULL); -r3_tree_insert_path(n, "/corge/bar/garply", NULL); -r3_tree_insert_path(n, "/corge/baz/foo", NULL); -r3_tree_insert_path(n, "/corge/baz/bar", NULL); -r3_tree_insert_path(n, "/corge/baz/qux", NULL); -r3_tree_insert_path(n, "/corge/baz/quux", NULL); -r3_tree_insert_path(n, "/corge/baz/grault", NULL); -r3_tree_insert_path(n, "/corge/baz/garply", NULL); -r3_tree_insert_path(n, "/corge/qux/foo", NULL); -r3_tree_insert_path(n, "/corge/qux/bar", NULL); -r3_tree_insert_path(n, "/corge/qux/baz", NULL); -r3_tree_insert_path(n, "/corge/qux/quux", NULL); -r3_tree_insert_path(n, "/corge/qux/grault", NULL); -r3_tree_insert_path(n, "/corge/qux/garply", NULL); -r3_tree_insert_path(n, "/corge/quux/foo", NULL); -r3_tree_insert_path(n, "/corge/quux/bar", NULL); -r3_tree_insert_path(n, "/corge/quux/baz", NULL); -r3_tree_insert_path(n, "/corge/quux/qux", NULL); -r3_tree_insert_path(n, "/corge/quux/grault", NULL); -r3_tree_insert_path(n, "/corge/quux/garply", NULL); -r3_tree_insert_path(n, "/corge/grault/foo", NULL); -r3_tree_insert_path(n, "/corge/grault/bar", NULL); -r3_tree_insert_path(n, "/corge/grault/baz", NULL); -r3_tree_insert_path(n, "/corge/grault/qux", NULL); -r3_tree_insert_path(n, "/corge/grault/quux", NULL); -r3_tree_insert_path(n, "/corge/grault/garply", NULL); -r3_tree_insert_path(n, "/corge/garply/foo", NULL); -r3_tree_insert_path(n, "/corge/garply/bar", NULL); -r3_tree_insert_path(n, "/corge/garply/baz", NULL); -r3_tree_insert_path(n, "/corge/garply/qux", NULL); -r3_tree_insert_path(n, "/corge/garply/quux", NULL); -r3_tree_insert_path(n, "/corge/garply/grault", NULL); -r3_tree_insert_path(n, "/grault/foo/bar", NULL); -r3_tree_insert_path(n, "/grault/foo/baz", NULL); -r3_tree_insert_path(n, "/grault/foo/qux", NULL); -r3_tree_insert_path(n, "/grault/foo/quux", NULL); -r3_tree_insert_path(n, "/grault/foo/corge", NULL); -r3_tree_insert_path(n, "/grault/foo/garply", NULL); -r3_tree_insert_path(n, "/grault/bar/foo", NULL); -r3_tree_insert_path(n, "/grault/bar/baz", NULL); -r3_tree_insert_path(n, "/grault/bar/qux", NULL); -r3_tree_insert_path(n, "/grault/bar/quux", NULL); -r3_tree_insert_path(n, "/grault/bar/corge", NULL); -r3_tree_insert_path(n, "/grault/bar/garply", NULL); -r3_tree_insert_path(n, "/grault/baz/foo", NULL); -r3_tree_insert_path(n, "/grault/baz/bar", NULL); -r3_tree_insert_path(n, "/grault/baz/qux", NULL); -r3_tree_insert_path(n, "/grault/baz/quux", NULL); -r3_tree_insert_path(n, "/grault/baz/corge", NULL); -r3_tree_insert_path(n, "/grault/baz/garply", NULL); -r3_tree_insert_path(n, "/grault/qux/foo", NULL); -r3_tree_insert_path(n, "/grault/qux/bar", NULL); -r3_tree_insert_path(n, "/grault/qux/baz", NULL); -r3_tree_insert_path(n, "/grault/qux/quux", NULL); -r3_tree_insert_path(n, "/grault/qux/corge", NULL); -r3_tree_insert_path(n, "/grault/qux/garply", NULL); -r3_tree_insert_path(n, "/grault/quux/foo", NULL); -r3_tree_insert_path(n, "/grault/quux/bar", NULL); -r3_tree_insert_path(n, "/grault/quux/baz", NULL); -r3_tree_insert_path(n, "/grault/quux/qux", NULL); -r3_tree_insert_path(n, "/grault/quux/corge", NULL); -r3_tree_insert_path(n, "/grault/quux/garply", NULL); -r3_tree_insert_path(n, "/grault/corge/foo", NULL); -r3_tree_insert_path(n, "/grault/corge/bar", NULL); -r3_tree_insert_path(n, "/grault/corge/baz", NULL); -r3_tree_insert_path(n, "/grault/corge/qux", NULL); -r3_tree_insert_path(n, "/grault/corge/quux", NULL); -r3_tree_insert_path(n, "/grault/corge/garply", NULL); -r3_tree_insert_path(n, "/grault/garply/foo", NULL); -r3_tree_insert_path(n, "/grault/garply/bar", NULL); -r3_tree_insert_path(n, "/grault/garply/baz", NULL); -r3_tree_insert_path(n, "/grault/garply/qux", NULL); -r3_tree_insert_path(n, "/grault/garply/quux", NULL); -r3_tree_insert_path(n, "/grault/garply/corge", NULL); -r3_tree_insert_path(n, "/garply/foo/bar", NULL); -r3_tree_insert_path(n, "/garply/foo/baz", NULL); -r3_tree_insert_path(n, "/garply/foo/qux", NULL); -r3_tree_insert_path(n, "/garply/foo/quux", NULL); -r3_tree_insert_path(n, "/garply/foo/corge", NULL); -r3_tree_insert_path(n, "/garply/foo/grault", NULL); -r3_tree_insert_path(n, "/garply/bar/foo", NULL); -r3_tree_insert_path(n, "/garply/bar/baz", NULL); -r3_tree_insert_path(n, "/garply/bar/qux", NULL); -r3_tree_insert_path(n, "/garply/bar/quux", NULL); -r3_tree_insert_path(n, "/garply/bar/corge", NULL); -r3_tree_insert_path(n, "/garply/bar/grault", NULL); -r3_tree_insert_path(n, "/garply/baz/foo", NULL); -r3_tree_insert_path(n, "/garply/baz/bar", NULL); -r3_tree_insert_path(n, "/garply/baz/qux", NULL); -r3_tree_insert_path(n, "/garply/baz/quux", NULL); -r3_tree_insert_path(n, "/garply/baz/corge", NULL); -r3_tree_insert_path(n, "/garply/baz/grault", NULL); -r3_tree_insert_path(n, "/garply/qux/foo", NULL); -r3_tree_insert_path(n, "/garply/qux/bar", NULL); -r3_tree_insert_path(n, "/garply/qux/baz", NULL); -r3_tree_insert_path(n, "/garply/qux/quux", NULL); -r3_tree_insert_path(n, "/garply/qux/corge", NULL); -r3_tree_insert_path(n, "/garply/qux/grault", NULL); -r3_tree_insert_path(n, "/garply/quux/foo", NULL); -r3_tree_insert_path(n, "/garply/quux/bar", NULL); -r3_tree_insert_path(n, "/garply/quux/baz", NULL); -r3_tree_insert_path(n, "/garply/quux/qux", NULL); -r3_tree_insert_path(n, "/garply/quux/corge", NULL); -r3_tree_insert_path(n, "/garply/quux/grault", NULL); -r3_tree_insert_path(n, "/garply/corge/foo", NULL); -r3_tree_insert_path(n, "/garply/corge/bar", NULL); -r3_tree_insert_path(n, "/garply/corge/baz", NULL); -r3_tree_insert_path(n, "/garply/corge/qux", NULL); -r3_tree_insert_path(n, "/garply/corge/quux", NULL); -r3_tree_insert_path(n, "/garply/corge/grault", NULL); -r3_tree_insert_path(n, "/garply/grault/foo", NULL); -r3_tree_insert_path(n, "/garply/grault/bar", NULL); -r3_tree_insert_path(n, "/garply/grault/baz", NULL); -r3_tree_insert_path(n, "/garply/grault/qux", NULL); -r3_tree_insert_path(n, "/garply/grault/quux", NULL); -r3_tree_insert_path(n, "/garply/grault/corge", NULL); - - - r3_tree_compile(n); - // r3_tree_dump(n, 0); - // match_entry *entry = zcalloc( 1 ); - - node *m; - m = r3_tree_match(n , "/qux/bar/corge", NULL); - fail_if( m == NULL ); - // r3_tree_dump( m, 0 ); - ck_assert_int_eq( *((int*) m->data), 999 ); - - - printf("Benchmarking...\n"); - BENCHMARK(string_dispatch) - r3_tree_matchl(n , "/qux/bar/corge", strlen("/qux/bar/corge"), NULL); - END_BENCHMARK(string_dispatch) - - BENCHMARK_SUMMARY(string_dispatch); - BENCHMARK_RECORD_CSV(string_dispatch, "bench_str.csv"); - - r3_tree_free(n); -} -END_TEST - START_TEST(test_feedback) { node * t = r3_tree_create(1); @@ -761,6 +391,7 @@ Suite* r3_suite (void) { Suite *suite = suite_create("blah"); TCase *tcase = tcase_create("testcase"); + tcase_set_timeout(tcase, 30); tcase_add_test(tcase, test_r3_node_construct_and_free); tcase_add_test(tcase, test_str_array); tcase_add_test(tcase, test_ltrim_slash); @@ -775,7 +406,7 @@ Suite* r3_suite (void) { tcase_add_test(tcase, test_pcre_patterns_insert_2); tcase_add_test(tcase, test_pcre_patterns_insert_3); tcase_add_test(tcase, test_feedback); - tcase_add_test(tcase, benchmark_str); + tcase_set_timeout(tcase, 30); suite_add_tcase(suite, tcase);