diff --git a/bench/Makefile b/bench/Makefile index 66dbde02..4e67e32b 100644 --- a/bench/Makefile +++ b/bench/Makefile @@ -271,7 +271,9 @@ bench-plain: ############################################################################ bench-mempool: - $(CXX) $(CFLAGS) $(CPPFLAGS) pool.cc `pkg-config --libs --cflags glib-2.0` -lboost_system -o bench-mempool.exe + @if test -n "$${BOOST}" ; then if test -n "$${GLIB}" ; then make bench-mempool0 BENCH_DEF="-DUSE_BOOST -DUSE_GLIB `pkg-config --libs --cflags glib-2.0` -lboost_system" ; else make bench-mempool0 BENCH_DEF="-DUSE_BOOST -lboost_system" ; fi ; else if test -n "$${GLIB}" ; then make bench-mempool0 BENCH_DEF="-DUSE_GLIB `pkg-config --libs --cflags glib-2.0`" ; else make bench-mempool0 ; fi ; fi +bench-mempool0: + $(CXX) $(CFLAGS) $(CPPFLAGS) pool.cc $(BENCH_DEF) -o bench-mempool.exe @./bench-mempool.exe ############################################################################ diff --git a/bench/pool.cc b/bench/pool.cc index 6ee322d4..6a26c6ea 100644 --- a/bench/pool.cc +++ b/bench/pool.cc @@ -51,9 +51,13 @@ #include #include +#ifdef USE_BOOST #include +#endif +#ifdef USE_GLIB #include +#endif static const size_t PAGE_SIZE = 4096; @@ -115,6 +119,8 @@ benchmark(std::string &&desc, std::function cb) * Boost::pool * ------------------------------------------------------------------------ */ +#ifdef USE_BOOST + template void benchmark_boost_pool() @@ -166,6 +172,7 @@ benchmark_boost_pool_create_and_destroy() } }); } +#endif /* * ------------------------------------------------------------------------ @@ -220,6 +227,7 @@ benchmark_mallocfree_free() * GLib slices * ------------------------------------------------------------------------ */ +#ifdef USE_GLIB template void benchmark_glib_slices() @@ -262,6 +270,7 @@ benchmark_glib_slices_free() } }); } +#endif /* * ------------------------------------------------------------------------ @@ -892,19 +901,23 @@ main() benchmark_mallocfree_free(); std::cout << std::endl; +#ifdef USE_GLIB benchmark_glib_slices(); benchmark_glib_slices_free(); benchmark_glib_slices(); benchmark_glib_slices_free(); std::cout << std::endl; - +#endif + +#ifdef USE_BOOST benchmark_boost_pool(); benchmark_boost_pool_free(); benchmark_boost_pool(); benchmark_boost_pool_free(); benchmark_boost_pool_create_and_destroy(); std::cout << std::endl; - +#endif + benchmark_ngx_pool(); benchmark_ngx_pool(); benchmark_ngx_pool_mix_free();