From f8154b23e9205989af399cd17d901d050354a680 Mon Sep 17 00:00:00 2001 From: c9s Date: Thu, 22 May 2014 16:24:24 +0800 Subject: [PATCH] Add --enable-stats option --- config.h | 110 -------------------------------------------- config.h.in | 9 ++++ configure.ac | 61 ++++++++++++++++++------ tests/bench_str.csv | 1 + 4 files changed, 56 insertions(+), 125 deletions(-) delete mode 100644 config.h diff --git a/config.h b/config.h deleted file mode 100644 index e766a43..0000000 --- a/config.h +++ /dev/null @@ -1,110 +0,0 @@ -/* config.h. Generated from config.h.in by configure. */ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* "whether graphviz is enable" */ -#define ENABLE_GRAPHVIZ test "x$enable_graphviz" = "xyes" - -/* Define to 1 if you have the header file. */ -#define HAVE_DLFCN_H 1 - -/* Define to 1 if you have the `gettimeofday' function. */ -#define HAVE_GETTIMEOFDAY 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if your system has a GNU libc compatible `malloc' function, and - to 0 otherwise. */ -#define HAVE_MALLOC 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if you have the `memset' function. */ -#define HAVE_MEMSET 1 - -/* Define to 1 if your system has a GNU libc compatible `realloc' function, - and to 0 otherwise. */ -#define HAVE_REALLOC 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the `strchr' function. */ -#define HAVE_STRCHR 1 - -/* Define to 1 if you have the `strdup' function. */ -#define HAVE_STRDUP 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the `strndup' function. */ -#define HAVE_STRNDUP 1 - -/* Define to 1 if you have the `strstr' function. */ -#define HAVE_STRSTR 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TIME_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -#define LT_OBJDIR ".libs/" - -/* Name of package */ -#define PACKAGE "r3" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "r3" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "r3 1.0.0" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "r3" - -/* Define to the home page for this package. */ -#define PACKAGE_URL "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "1.0.0" - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Version number of package */ -#define VERSION "1.0.0" - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef __cplusplus -/* #undef inline */ -#endif - -/* Define to rpl_malloc if the replacement function should be used. */ -/* #undef malloc */ - -/* Define to rpl_realloc if the replacement function should be used. */ -/* #undef realloc */ - -/* Define to `unsigned int' if does not define. */ -/* #undef size_t */ diff --git a/config.h.in b/config.h.in index c74bb06..14e8361 100644 --- a/config.h.in +++ b/config.h.in @@ -3,6 +3,9 @@ /* "whether graphviz is enable" */ #undef ENABLE_GRAPHVIZ +/* "whether statistics is enable" */ +#undef ENABLE_STATS + /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H @@ -12,6 +15,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H +/* Define to 1 if you have the header file. */ +#undef HAVE_JEMALLOC_JEMALLOC_H + /* Define to 1 if your system has a GNU libc compatible `malloc' function, and to 0 otherwise. */ #undef HAVE_MALLOC @@ -90,6 +96,9 @@ /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS +/* Define to 1 if you have the PATH_MAX macro. */ +#undef USE_JEMALLOC + /* Version number of package */ #undef VERSION diff --git a/configure.ac b/configure.ac index b6fd07b..64fe857 100644 --- a/configure.ac +++ b/configure.ac @@ -7,12 +7,6 @@ LT_INIT AC_PROG_CC AC_PROG_CC_STDC -# AM_PATH_CHECK() -AM_PATH_CHECK(,[have_check="yes"], - AC_MSG_WARN([Check not found; cannot run unit tests!]) - [have_check="no"]) -AM_CONDITIONAL(HAVE_CHECK, test x"$have_check" = "xyes") - AC_CHECK_HEADERS([stdlib.h string.h sys/time.h]) # Checks for typedefs, structures, and compiler characteristics. @@ -28,6 +22,49 @@ AC_CHECK_FUNCS([gettimeofday memset strchr strdup strndup strstr]) PKG_PROG_PKG_CONFIG + + + +AC_ARG_WITH([malloc], AS_HELP_STRING([--without-malloc], [Use the default malloc])) + +AS_IF([test "x$with_malloc" == "xjemalloc"], + [AC_CHECK_HEADERS([jemalloc/jemalloc.h], [ + found_jemalloc=yes; break + ])]) + +if test "x$found_jemalloc" == "xyes" ; then + +AC_MSG_CHECKING([Checking jemalloc version]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[ + #ifdef JEMALLOC_VERSION_MAJOR > 2 + return 0; + #endif + return 1; + ]])], + [ + AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED([USE_JEMALLOC], 1, [Define to 1 if you have the PATH_MAX macro.]) + have_jemalloc=yes + ], + [ + AC_MSG_RESULT([no]) + AC_DEFINE_UNQUOTED([USE_JEMALLOC], 0, [Define to 1 if you have the PATH_MAX macro.]) + have_jemalloc=no + ] + ) +fi +AM_CONDITIONAL(USE_JEMALLOC, test "x$have_jemalloc" = "xyes") +AM_CONDITIONAL(ENABLE_GRAPHVIZ, test "x$enable_graphviz" = "xyes") + + + +AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug], [enable debug]), [],[enable_debug=unset]) +AM_CONDITIONAL(ENABLE_DEBUG, test "x$enable_debug" = "xyes") + +AC_ARG_ENABLE(stats, AS_HELP_STRING([--enable-stats], [enable statistics]), [] ,[enable_stats=unset]) +AC_DEFINE(ENABLE_STATS, test "x$enable_stats" = "xyes", "whether statistics is enable") + AC_ARG_ENABLE(graphviz, AS_HELP_STRING([--enable-graphviz], [enable graphviz support]), @@ -37,18 +74,12 @@ if test "x$enable_graphviz" != "xunset" ; then AC_SUBST(GVC_DEPS_CFLAGS) AC_SUBST(GVC_DEPS_LIBS) fi - -AC_ARG_ENABLE(debug, - AS_HELP_STRING([--enable-debug], - [enable debug]), - , enable_debug=unset) - -AM_CONDITIONAL(ENABLE_DEBUG, test "x$enable_debug" = "xyes") -AM_CONDITIONAL(ENABLE_GRAPHVIZ, test "x$enable_graphviz" = "xyes") +# include flags AC_DEFINE(ENABLE_GRAPHVIZ, test "x$enable_graphviz" = "xyes", "whether graphviz is enable") +PKG_CHECK_MODULES([CHECK], [check >= 0.9.4]) -PKG_CHECK_MODULES(DEPS, [libpcre check]) +PKG_CHECK_MODULES(DEPS, [libpcre]) AC_SUBST(DEPS_CFLAGS) AC_SUBST(DEPS_LIBS) AC_CONFIG_FILES([ diff --git a/tests/bench_str.csv b/tests/bench_str.csv index 1b3d4f7..b92c273 100644 --- a/tests/bench_str.csv +++ b/tests/bench_str.csv @@ -432,3 +432,4 @@ 1400606491,14030387.83 1400606523,13157029.51 1400606567,13999364.95 +1400747045,12800263.03